Amazon-FreeRTOS with Emwin on LPC54628

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Amazon-FreeRTOS with Emwin on LPC54628

1,134 Views
raymondchin
Contributor I

Hi..

Has anyone had any issues with running Amazon-FreeRTOS with EMWIN on a LPCxpresso54628 board?

I am using MCUExpresso 10.2.1, with the 2.4.1 SDK for the LPCxpresso54628 board.

I ran the LPC54608 Emwin touch and draw example, running on the older FreeRTOS, on the LPCxpresso54628 board and it ran fine.

And when I tried porting the code over to the Amazon-FreeRTOS, I get the semihost_hardfault on the LPCxpresso54628 board .  I tracked it down to the execution of GUI_Init().  I also noticed that with Amazon-FreeRTOS, the heap memory becomes 100% full, unlike the older version of FreeRTOS - this is also a symptom of the Amazon-FreeRTOS examples.  I played with moving some of the code/data to external SDRAM using the linker, but to no success..except for harder crashes, in which I have to restart MCUExpresso, and power down the development board.

Does anyone have any insight to a fix?

Regards,

0 Kudos
1 Reply

721 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello Raymond Chin,

The touch and draw example provided in the next application note (https://www.nxp.com/docs/en/application-note/TN00028.zip) is based on the version 2.2 of the SDK. The current version of the SDK that comes with Amazon-FreeRTOS is the version 2.4.1. From version 2.2 to 2.4.1, considerable changes were made to the emwin drivers. 

In the example of the application note TN00028 in the file  freertos_emwin_touch_and_draw.c you have functions like the following: 

void GUI_X_Config(void)
{
    /* Assign work memory area to emWin */
    GUI_ALLOC_AssignMemory((void *)GUI_MEMORY_ADDR, GUI_NUMBYTES);

    /* Select default font */
    GUI_SetDefaultFont(GUI_FONT_6X8);
}

void GUI_X_Init(void)
{
     
}

void GUI_X_InitOS(void)
{
     /* Create a Mutex lock*/
     xQueueMutex = xSemaphoreCreateMutex();
     configASSERT(xQueueMutex !=NULL);
     
     vSemaphoreCreateBinary(xSemaTxDone);
     configASSERT(xSemaTxDone != NULL);
}
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

All the GUI functions are called at some point by the function GUI_Init. 

When you  create a new project with the New project wizard of MCUXpresso and you select the emwin drivers based on the SDK 2.4.1 you will have two new files in the emwin folder within your workspace. 

pastedImage_7.png

If you open the file emwin_support.c you will see that all the functions that in the example of the application note you have in the file freertos_emwin_touch_and_draw.c are declared in this file, but they are empty so you can adapt each function to your needs. In this case since you have the example of the application note you only need complete the declarations of the functions that are located in the file emwin_support.c based on the functions that are on the file freertos_emwin_touch_and_draw.c. At the end your file emwin_support.c should look like the following (I will show just some of the functions but you need to complete all the functions that you need based on the freertos_emwin_touch_and_draw.c file of the application note).

void LCD_X_Config(void)
{
    GUI_DEVICE_CreateAndLink(GUIDRV_LIN_16, GUICC_565, 0, 0);

    LCD_SetSizeEx(0, LCD_WIDTH, LCD_HEIGHT);
    LCD_SetVSizeEx(0, LCD_WIDTH, LCD_HEIGHT);

    LCD_SetVRAMAddrEx(0, (void *)VRAM_ADDR);
}

int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void *pData)
{
     return 0;
}

void GUI_X_Config(void)
{
    /* Assign work memory area to emWin */
    GUI_ALLOC_AssignMemory((void *)GUI_MEMORY_ADDR, GUI_NUMBYTES);

    /* Select default font */
    GUI_SetDefaultFont(GUI_FONT_6X8);
}

Once you implement these changes you won't have any problems on migrating to Amazon-FreeRTOS. 

Regarding the other question that you made:

The heap memory becomes 100% full

You need to measure the heap usage until you set the tasks and start the scheduler, otherwise you will see incorrect information. 

Hope it helps!

Victor.

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------