<span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">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.</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">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:</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">int GUI_X_GetTime(void)</span>
<span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">{</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">return ((int) xTaskGetTickCount());</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">}</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">void GUI_X_Delay(int ms)</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">{</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">vTaskDelay( ms );</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">}</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">my GUI task is currently the only task that I am using</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">int main(void)</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">{</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">xTaskCreate(tskGUI, (signed char *) "tskGUI", 2048, NULL, tskGUI_PRIORITY, NULL);</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">vTaskStartScheduler();</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">while (1);</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">return 0;</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">}</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">I stripped my GUI task down so that all it creates is a frame window</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">static const GUI_WIDGET_CREATE_INFO _aFrameWinControl[] =</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">{</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">{ FRAMEWIN_CreateIndirect, "Control", 0, 0, 0, LCD_WIDTH, LCD_HEIGHT, 0, 0 },</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">};</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">static void _cbFrameWinControl(WM_MESSAGE* pMsg)</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">{</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">int xSize, ySize;</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">switch(pMsg->MsgId)</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">{</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">case WM_INIT_DIALOG:</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">break;</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">case WM_PAINT:</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">xSize = WM_GetWindowSizeX(pMsg->hWin);</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">ySize = WM_GetWindowSizeY(pMsg->hWin);</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">GUI_DrawGradientH(0, 0, xSize - 1, ySize - 1, 0xFFFFFF, 0xDCCEC0);</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">break;</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">default:</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">WM_DefaultProc(pMsg);</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">}</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">}</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">void tskGUI(void *pvParameters)</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">{</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">GUI_Init();</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">WM_SetCreateFlags (WM_CF_MEMDEV);</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">WM_SetDesktopColor(GUI_BLACK);</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">GUI_CreateDialogBox(_aFrameWinControl, GUI_COUNTOF(_aFrameWinControl), &_cbFrameWinControl, WM_HBKWIN, 0, 0);</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">while (1)</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">{</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">GUI_Delay(10);</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">}</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">}</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">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.</span><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><br style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;" /><span style="color: #57595a; font-family: 'Trebuchet MS', Arial, sans-serif; font-size: 13px; line-height: normal;">Has anyone encountered a similar problem and if so, how did you resolve it?</span>