Friday, February 23rd 2018, 3:35am UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Date of registration: Sep 17th 2012

Posts: 17

1

Tuesday, January 8th 2013, 1:54pm

Strange behaviour on GUI_MEMDEV_Delete() function

Hi all,

I'm using emWin 5.18 on NXP LPC1788 device with gcc compiler.
Sometimes I see that calling GUI_MEMDEV_Delete(memdev) causes HardFault_Handler(), that is microprocessor crash ..... It does not matter whether memdev was created or not before GUI_MEMDEV_Delete(memdev) call. It is not a problem due to memory overflow because often it happens when I call routine the first time.
memdev is created with GUI_MEMDEV_CreateFixed() and normally it works properly.
Just to try, I saw that it seems to work properly if I use WM_DeleteWindow(memdev) instead of GUI_MEMDEV_Delete(memdev)!!

Any suggestions/info?

Thanks and best regards,

Valter Rasicci

Date of registration: Sep 17th 2012

Posts: 17

2

Wednesday, January 9th 2013, 2:26pm

Strange behaviour on GUI_MEMDEV_Delete() function

Just for confirmation, look at this source code lines:


GUI_MEMDEV_Handle md[5];


/*THIS for CYCLE WORKS PERFECTLY (even though it is formally erroneous)!!*/
for(i=0;i<5;i++)
WM_DeleteWindow(md);




/*THIS for CYCLE CAUSES microprocessor HardFault() (even though it is formally correct)!!*/
for(i=0;i<5;i++)
GUI_MEMDEV_Delete(md[i]);


Best regards,

Valter Rasicci

Date of registration: May 26th 2009

Posts: 1,022

3

Wednesday, January 16th 2013, 9:26am

Hello Valter,

How do you know that using the function WM_DeleteWindow() works properly?
Would it be possible to provide me with the code which makes the microprocessor crash?

Best regards,
Adrian

Date of registration: Sep 17th 2012

Posts: 17

4

Wednesday, January 16th 2013, 7:34pm

Questions MEMDEV managment and gcc toolchain

Hi Adrian,

sorry for my message that was not properly formatted. Please look at attached file containing considerations and source code.

Best regards,

Valter Rasicci
valterrasicci has attached the following file:
  • for_Adrian.pdf (307.66 kB - 1,097 times downloaded - Last download: Feb 20th 2018, 9:00pm)

This post has been edited 2 times, last edit by "valterrasicci" (Jan 16th 2013, 10:59pm)


Date of registration: Sep 17th 2012

Posts: 17

5

Tuesday, January 22nd 2013, 8:37pm

Hi Adrian,
Any news?

Valter

Date of registration: May 26th 2009

Posts: 1,022

6

Friday, January 25th 2013, 9:48am

Hello Valter,

Your code does not create any Memory Device. Deleting Memory Devices will not work if they are not created in a previous step.

Best regards,
Adrian

Armin

Beginner

Date of registration: Aug 14th 2013

Posts: 9

7

Wednesday, August 14th 2013, 4:07pm

Software hungs after calling of "WM_DeleteWindow"

Hello Adrian,

I have the problem that after the call of WM_DeleteWindow the software hungs!
I don't want to use GUI_Delay as the code you can see in the attached file:
How can i create and delete objects without delays?

Thanks
Armin
Armin has attached the following file:
  • WM_Sample.zip (1.98 kB - 473 times downloaded - Last download: Yesterday, 5:53am)

Date of registration: May 26th 2009

Posts: 1,022

8

Thursday, August 15th 2013, 3:02pm

Hello Armin,

Have you tried to use GUI_Exec()? This processes all pending events, but does not delay the application.

Best regards,
Adrian

Armin

Beginner

Date of registration: Aug 14th 2013

Posts: 9

9

Friday, August 16th 2013, 12:09pm

Application with EmWin hungs

Hello Adrian,
My Application with EMWin using hungs after of some oppening and closing of the Screen(the simpified code is to see as below), please write me what can i do, whereby the applcation can run stable?
This problem is very important which appear by other users too, please write me all ways that you know to solve this problem.
/************************************************************************************************************************************************************************/
// Global variables
static WM_HWIN m_Screen1=(GUI_HWIN)NULL;
BUTTON_Handle m_Button1=(GUI_HWIN)NULL;
/************************************************************************************************************************************************************************/
// Event functions
static void _cbScreen1(WM_MESSAGE * pMsg)
{
// Enable Antialiasing
GUI_AA_EnableHiRes();
// Set Antialiasing factor to maximal value
GUI_AA_SetFactor(6);
// Hide the cursor
GUI_CURSOR_Hide();
switch (pMsg->MsgId)
{
case WM_TOUCH:
return;
case WM_PID_STATE_CHANGED:
break;
case WM_KEY:
break;
case WM_PAINT:
// Draw some Bitmaps and write texts on the screen with emWin-Functions GUI_DrawBitmap and GUI_DispStringInRectEx
break;
}
}
static void _cButton1(WM_MESSAGE * pMsg)
{
// Enable Antialiasing
GUI_AA_EnableHiRes();
// Set Antialiasing factor to maximal value
GUI_AA_SetFactor(6);
// Hide the cursor
GUI_CURSOR_Hide();
switch (pMsg->MsgId)
{
case WM_TOUCH:
return;
case WM_PID_STATE_CHANGED:
break;
case WM_KEY:
break;
case WM_PAINT:
// Draw some Bitmaps and write texts on the screen with emWin-Functions GUI_DrawBitmap and GUI_DispStringInRectEx
break;
}
}
/************************************************************************************************************************************************************************/
// Screen functions
void ShowScreen1()
{
WM_DisableMemdev(WM_HBKWIN);
GUI_Exec();
m_Screen1= WM_CreateWindowAsChild(0,0,320,240, WM_HBKWIN, WM_CF_SHOW | WM_CF_MEMDEV, _cbScreen1, sizeof(WM_HWIN));
m_Button1= BUTTON_CreateEx(0,0,320,37,m_Screen1,WM_CF_SHOW | WM_CF_MEMDEV,0,GUI_ID_BUTTON0);
WM_SetCallback(m_Button1, _cButton1);
WM_SendMessageNoPara(m_Button1, INIT_BUTTON);
}
void CloseScreen1()
{
if(m_Button1!=(GUI_HWIN)NULL)
{
BUTTON_Delete(m_Button1);
m_Button1=(GUI_HWIN)NULL;
}
if(m_hHomeGNCScreenWin!=(GUI_HWIN)NULL)
{
WM_DetachWindow(m_Screen1);
WM_DeleteWindow(m_Screen1);
m_Screen1=(GUI_HWIN)NULL;
}
}
/************************************************************************************************************************************************************************/
// main
int main(void)
{
GUI_Init();
while(1)
{
ShowScreen1();
GUI_Delay(1000);
CloseScreen1();
GUI_Delay(1000);
}
return(0);
}

Thanks
Armin

Date of registration: May 26th 2009

Posts: 1,022

10

Monday, August 19th 2013, 9:36am

Hello Armin,

Please make sure the windows are deleted after use. If there is no memory left the application might stop working properly.

Best regards,
Adrian

Armin

Beginner

Date of registration: Aug 14th 2013

Posts: 9

11

Monday, August 19th 2013, 1:11pm

Child-Window and Controls are deleted before creating, anyway appliaction hangs

Hello Adrain,
As you see in my Code above (on this side), i delete the screen(child window and Buttons) with "BUTTON_Delete" and "WM_DeleteWindow" and after that i create the screen again, i saw very often that the application hangs on "BUTTON_Delete" or "WM_DeleteWindow".
My Appication is simplay as below:
void main()
{
GUI_Init();
while(1)
{
ShowScreen1();
GUI_Delay(200);
DeleteScrteen1()
GUI_Delay(200);
}
}
// For more details please see my code above(on this page)
Best regards
Armin

Armin

Beginner

Date of registration: Aug 14th 2013

Posts: 9

12

Monday, August 19th 2013, 1:14pm

Hello Adrian,
I mean of course "Close Screen1();" instead of "DeleteScrteen1();" in the main loop.
Best regards
Armin

Date of registration: May 26th 2009

Posts: 1,022

13

Tuesday, August 20th 2013, 9:45am

Hello Armin,

Please check the value contained by your handle variables after the according window has been deleted.

Best regards,
Adrian

Armin

Beginner

Date of registration: Aug 14th 2013

Posts: 9

14

Tuesday, August 20th 2013, 12:52pm

Hello Adrian,
I had defined my handle variables af follow:
static WM_HWIN m_Screen1=(GUI_HWIN)NULL;
static BUTTON_Handle m_Button1=(GUI_HWIN)NULL;
I had tried them with volatile too, as follow:
volatile WM_HWIN m_Screen1=(GUI_HWIN)NULL;
volatile BUTTON_Handle m_Button1=(GUI_HWIN)NULL;
After several time of cretaing and deleting the the windows(in a display page), the application hangs in the function "BUTTON_Delete(m_Button1);" or "WM_DeleteWindow(m_Screen1);"
BUTTON_Delete is defined as follow:
#define BUTTON_Delete(hObj) WM_DeleteWindow (hObj)

EmWin doesn't give any result back by these functions !!!, you can inform the developers to implement back Results for these functions please.
Please see My Email from Aug.14.2013 on this page for more informations.
Best regards
Armin

Date of registration: May 26th 2009

Posts: 1,022

15

Wednesday, August 21st 2013, 10:41am

Hello Armin,

Please note that calling the function WM_DeleteWindow() with a handle to an existing window will always work. In order to determine possible errors, please define GUI_DEBUG_LEVEL with a value equal to or higher than GUI_DEBUG_LEVEL_LOG_WARNINGS.

Best regards,
Adrian

Armin

Beginner

Date of registration: Aug 14th 2013

Posts: 9

16

Thursday, August 22nd 2013, 7:50am

Hello Adrian,
In my project the GUI_DEBUG_LEVEL is set to GUI_DEBUG_LEVEL_LOG_WARNINGS, with this value or GUI_DEBUG_LEVEL_LOG_ALL the application crashes anyway.
The Application crash by "WM_DeleteWindow(m_Screen1);"
When the WM_DeleteWindow(m_Screen1); works, the windows handle variable has the same value before and after call of this function !
The Crash happens after about 10 times creating and deleting the childwindow.
I don't use a GUI_Delay between creating,show and deleting the child-window.
Please write me how long time as minimum must i set as delay between creating and deleting a child window?
Shall i use GUI_Delay or a wait loop, please think on GUI_Exec(); in the main loop?
Is it exists a way in emwin to find out why the crash in WM_DeleteWindow(...) happens?
Best regards
Armin

Date of registration: May 26th 2009

Posts: 1,022

17

Thursday, August 22nd 2013, 9:16am

Hello Armin,

Have you implemented the function GUI_X_Warn()? It is called to output warnings generated by emWin. For detailed information on how to handle debug output, please refer to the chapter "Configuration" in the emWin user manual. The reason for the problem is quite simple. You try to delete a window which is already deleted.

Best regards,
Adrian

Armin

Beginner

Date of registration: Aug 14th 2013

Posts: 9

18

Thursday, August 22nd 2013, 11:57am

Hello Adrian,
Please see the documented code below, and read the qeustions.
volatile GUI_ALLOC_DATATYPE m_GUI_ALLOC_DATATYPE;
m_GUI_ALLOC_DATATYPE=GUI_ALLOC_GetNumUsedBytes();
// Result: 984 Bytes are used
// m_hButton1 is created and has the value 4
if(m_hButton1!=(GUI_HWIN)NULL)
{
BUTTON_Delete(m_hButton1);
// After ca. 5 times hangs the Applications in BUTTON_Delete-Function and doesn't come out, why?
// After call of BUTTON_Delete-Function has m_hButton1 the value 4 , why doesn't set BUTTON_Delete-Function the value of m_hButton1 of NULL ?
m_hButton1=(GUI_HWIN)NULL; // Manuelly setting of m_hButton1 to NULL
}
m_GUI_ALLOC_DATATYPE=GUI_ALLOC_GetNumUsedBytes();
// 852 Bytes are used
Best regards
Armin

Date of registration: May 26th 2009

Posts: 1,022

19

Friday, August 23rd 2013, 10:03am

Hello Armin,

Could you please answer the question from my previous post?

Have you implemented the function GUI_X_Warn()?

The value contained by the window handle is not changed by the function BUTTON_Delete(), because it is set by the ...Create()-functions. Regular calls of a ...Delete()-function without a prior call of a ...Create()-function are not recommended.

Best regards,
Adrian

Armin

Beginner

Date of registration: Aug 14th 2013

Posts: 9

20

Friday, August 23rd 2013, 1:27pm

Hello Adrian,
I didn't try the function GUI_X_Warn() because of missing time, if you have an example you can send me it please, i see to take informations in internet too.
As i wrote you the windows handle were set(windows were created) befor of calling of WM_DeleteWindow(...), it works well, but after several times of creating and deleting of them, the application hangs in the function WM_DeleteWindow(...)
Best regards
Armin