Cause emWin library definitely has a memory allocation bug (look my another thread, take project for live example),
I am trying to free memory by crude power, I make this inclusion in my code:
if (GUI_ALLOC_GetNumFreeBytes() < 2 * 1024) {
GUI_Exit();
GUI_Init();
}
GUI_Exit() works fine, LCD becomes blank.
But when I try to reinitialize GUI, emWin goes again to function LCD_X_Config and mcu catch hard reset at the attempt of repeated driver configuration:
void LCD_X_Config(void) {
GUI_DEVICE *pDevice;
CONFIG_FLEXCOLOR pConfig = { 0 };
GUI_PORT_API PortAPI = { 0 };
// Set display driver and color conversion
pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_565, 0, 0);
//Configure driver
pConfig.Orientation = GUI_SWAP_XY | GUI_MIRROR_X;
GUIDRV_FlexColor_Config(pDevice, &pConfig); //here it halts because of pDevice= 0x0.
// Display driver configuration
LCD_SetSizeEx(0, XSIZE_PHYS, YSIZE_PHYS);
LCD_SetVSizeEx(0, XSIZE_PHYS, YSIZE_PHYS);
//Set pointers for write-read hardware function
PortAPI.pfWrite16_A0 = LCD_set_register;
PortAPI.pfWrite16_A1 = LCD_write_data;
PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple;
PortAPI.pfRead16_A1 = LCD_read_data;
PortAPI.pfReadM16_A1 = LcdReadDataMultiple;
// Find the current LCD and initialize GUIDRV
GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66708, GUIDRV_FLEXCOLOR_M16C0B16);
//Add touch function
unsigned TouchOrientation = ((GUI_SWAP_XY * LCD_GetSwapXY()) | (GUI_MIRROR_X * LCD_GetMirrorX()));
GUI_TOUCH_SetOrientation(TouchOrientation);
/*
* int GUI_TOUCH_Calibrate(int Coord, int Log0, int Log1, int Phys0, int Phys1);
* Coord GUI_COORD_X for X-axis, GUI_COORD_Y for Y-axis.
* Log0 Logical value 0 in pixels.
* Log1 Logical value 1 in pixels.
* Phys0 A/D converter value for Log0.
* Phys1 A/D converter value for Log1.
*/
GUI_TOUCH_Calibrate(GUI_COORD_X,
0, YSIZE_PHYS,
AD_VAL_LOG_0_Y_COORD, AD_VAL_LOG_1_Y_COORD);
GUI_TOUCH_Calibrate(GUI_COORD_Y,
0, XSIZE_PHYS,
AD_VAL_LOG_0_X_COORD, AD_VAL_LOG_1_X_COORD);
}
For information:
My emWin library has version 5.28.
I looked in manual (p.48) - no any clue for this issue.
I am trying to free memory by crude power, I make this inclusion in my code:
if (GUI_ALLOC_GetNumFreeBytes() < 2 * 1024) {
GUI_Exit();
GUI_Init();
}
GUI_Exit() works fine, LCD becomes blank.
But when I try to reinitialize GUI, emWin goes again to function LCD_X_Config and mcu catch hard reset at the attempt of repeated driver configuration:
void LCD_X_Config(void) {
GUI_DEVICE *pDevice;
CONFIG_FLEXCOLOR pConfig = { 0 };
GUI_PORT_API PortAPI = { 0 };
// Set display driver and color conversion
pDevice = GUI_DEVICE_CreateAndLink(GUIDRV_FLEXCOLOR, GUICC_565, 0, 0);
//Configure driver
pConfig.Orientation = GUI_SWAP_XY | GUI_MIRROR_X;
GUIDRV_FlexColor_Config(pDevice, &pConfig); //here it halts because of pDevice= 0x0.
// Display driver configuration
LCD_SetSizeEx(0, XSIZE_PHYS, YSIZE_PHYS);
LCD_SetVSizeEx(0, XSIZE_PHYS, YSIZE_PHYS);
//Set pointers for write-read hardware function
PortAPI.pfWrite16_A0 = LCD_set_register;
PortAPI.pfWrite16_A1 = LCD_write_data;
PortAPI.pfWriteM16_A1 = LcdWriteDataMultiple;
PortAPI.pfRead16_A1 = LCD_read_data;
PortAPI.pfReadM16_A1 = LcdReadDataMultiple;
// Find the current LCD and initialize GUIDRV
GUIDRV_FlexColor_SetFunc(pDevice, &PortAPI, GUIDRV_FLEXCOLOR_F66708, GUIDRV_FLEXCOLOR_M16C0B16);
//Add touch function
unsigned TouchOrientation = ((GUI_SWAP_XY * LCD_GetSwapXY()) | (GUI_MIRROR_X * LCD_GetMirrorX()));
GUI_TOUCH_SetOrientation(TouchOrientation);
/*
* int GUI_TOUCH_Calibrate(int Coord, int Log0, int Log1, int Phys0, int Phys1);
* Coord GUI_COORD_X for X-axis, GUI_COORD_Y for Y-axis.
* Log0 Logical value 0 in pixels.
* Log1 Logical value 1 in pixels.
* Phys0 A/D converter value for Log0.
* Phys1 A/D converter value for Log1.
*/
GUI_TOUCH_Calibrate(GUI_COORD_X,
0, YSIZE_PHYS,
AD_VAL_LOG_0_Y_COORD, AD_VAL_LOG_1_Y_COORD);
GUI_TOUCH_Calibrate(GUI_COORD_Y,
0, XSIZE_PHYS,
AD_VAL_LOG_0_X_COORD, AD_VAL_LOG_1_X_COORD);
}
For information:
My emWin library has version 5.28.
I looked in manual (p.48) - no any clue for this issue.
The post was edited 1 time, last by Constantine ().