emWin crash at increasing the Ram for Stack - Page 1
Forum section: electronics / general

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 20, 2017, 02:12:09 pm
content: Hi,I wanted to do just a simple LCD driver that only prints data into ram, there is no actual LCD connected to the MCU, my MCU is STM32F103RBT6 and here is the content of my GUIConf and LCDConf files, the main program would do ok, after I call the GUI_Init(); function if I set the #define GUI_NUMBYTES 0x400, but when I increase it to something more, the program just crash, with the 0x400 stack also if I use any drawing functions the program would crash again. do you have any Idea what might be wrong?the guiconf fileCode:#include "GUI.h"/*********************************************************************** Defines************************************************************************///// Define the available number of bytes available for the GUI//#define GUI_NUMBYTES 0x400//// Define the average block size//#define GUI_BLOCKSIZE 0x80/*********************************************************************** Public code************************************************************************//*********************************************************************** GUI_X_Config** Purpose:* Called during the initialization process in order to set up the* available memory for the GUI.*/void GUI_X_Config(void) {//// 32 bit aligned memory area//static U32 aMemory[GUI_NUMBYTES / 4];//// Assign memory to emWin//GUI_ALLOC_AssignMemory(aMemory, GUI_NUMBYTES);GUI_ALLOC_SetAvBlockSize(GUI_BLOCKSIZE);}the lcdconf fileCode:#include "GUI.h"#include "GUIDRV_Lin.h"#define XSIZE_PHYS 128#define YSIZE_PHYS 32//// Color conversion//#define COLOR_CONVERSION GUICC_1//// Display driver//#define DISPLAY_DRIVER GUIDRV_LIN_1/*********************************************************************** Configuration checking************************************************************************/#ifndef XSIZE_PHYS#error Physical X size of display is not defined!#endif#ifndef YSIZE_PHYS#error Physical Y size of display is not defined!#endif#ifndef COLOR_CONVERSION#error Color conversion not defined!#endif#ifndef DISPLAY_DRIVER#error No display driver defined!#endif/*********************************************************************** Public code************************************************************************//*********************************************************************** LCD_X_Config** Function description* Called during the initialization process in order to set up the* display driver configuration.*/void LCD_X_Config(void) {//// Set display driver and color conversion for 1st layer//GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER, COLOR_CONVERSION, 0, 0);//// Display driver configuration//LCD_SetSizeEx (0, XSIZE_PHYS, YSIZE_PHYS);// Physical display size in pixelsLCD_SetVSizeEx(0, XSIZE_PHYS, YSIZE_PHYS );// Virtual display size in pixels}/*********************************************************************** LCD_X_DisplayDriver** Function description* Display driver callback function. This function is called by the* Display driver for certain purposes. Using GUIDRV_Win32 it is not* required to react to any command.*/int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) {GUI_USE_PARA(LayerIndex);GUI_USE_PARA(Cmd);GUI_USE_PARA(pData);return 0;}

author: rstofer
author_rank: Super Contributor
timestamp: August 20, 2017, 09:14:27 pm
content: It seems that the allocate functions are using the heap. Did you overrun the maximum size of the heap? Is you linker script somehow putting stuff in the wrong place given the expanded heap?FWIW, I try to avoid using a heap at every opportunity. There just isn't enough memory in small embedded processors to allow a heap manager to run rampant.

author: ali_asadzadeh
author_rank: Super Contributor
timestamp: August 21, 2017, 05:36:02 am
content: Thanks, But I have done it before on similar MCU's!