emWin and FreeRTOS

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • emWin and FreeRTOS

    I am trying to build a project that runs emWin from a single FreeRTOS task on an LPC4357 platform. Unfortunately, my project hardfaults after a few minutes.

    I started by building a project that ran emWin as a standalone application. That project runs fine without any issues. I then modified the GUI_X.c file to use the FreeRTOS timing:

    Source Code

    1. int GUI_X_GetTime(void)
    2. {
    3. return ((int) xTaskGetTickCount());
    4. }
    5. void GUI_X_Delay(int ms)
    6. {
    7. vTaskDelay( ms );
    8. }

    my GUI task is currently the only task that I am using

    Source Code

    1. int main(void)
    2. {
    3. xTaskCreate(tskGUI, (signed char *) "tskGUI", 2048, NULL, tskGUI_PRIORITY, NULL);
    4. vTaskStartScheduler();
    5. while (1);
    6. return 0;
    7. }

    I stripped my GUI task down so that all it creates is a frame window

    Source Code

    1. static const GUI_WIDGET_CREATE_INFO _aFrameWinControl[] =
    2. {
    3. { FRAMEWIN_CreateIndirect, "Control", 0, 0, 0, LCD_WIDTH, LCD_HEIGHT, 0, 0 },
    4. };
    5. static void _cbFrameWinControl(WM_MESSAGE* pMsg)
    6. {
    7. int xSize, ySize;
    8. switch(pMsg->MsgId)
    9. {
    10. case WM_INIT_DIALOG:
    11. break;
    12. case WM_PAINT:
    13. xSize = WM_GetWindowSizeX(pMsg->hWin);
    14. ySize = WM_GetWindowSizeY(pMsg->hWin);
    15. GUI_DrawGradientH(0, 0, xSize - 1, ySize - 1, 0xFFFFFF, 0xDCCEC0);
    16. break;
    17. default:
    18. WM_DefaultProc(pMsg);
    19. }
    20. }
    21. void tskGUI(void *pvParameters)
    22. {
    23. GUI_Init();
    24. WM_SetCreateFlags (WM_CF_MEMDEV);
    25. WM_SetDesktopColor(GUI_BLACK);
    26. GUI_CreateDialogBox(_aFrameWinControl, GUI_COUNTOF(_aFrameWinControl), &_cbFrameWinControl, WM_HBKWIN, 0, 0);
    27. while (1)
    28. {
    29. GUI_Delay(10);
    30. }
    31. }
    Display All

    The application will run for a minute or two before hard faulting with INVPC ("Invalid PC load Usage Fault, caused by an invalid EXC_RETURN value:"). This seems to occur on the return from SVC within the yield function. My first thought was a stack overflow. However I have since expanded both the main stack used by ISRs and the task stack and added some stack monitoring. Neither stack appears to overflow.

    Has anyone encountered a similar problem and if so, how did you resolve it?