This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LS1224: Correct approach for HalCoGen usage with MPU enabled FreeRTOS

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN

Hi :)

What is the correct approach for using HalCoGen generated drivers when MPU is enabled?

For example, when I try to use the SCI driver to receive some data using interrupts, I can call sciReceive() function. The normal unprivileged FreeRTOS task which calls sciReceive() function has only access to its own stack and additional task-specific memory regions if defined. The problem is that HalCoGen uses some static global structures that sciReceive() refers to (in this case g_sciTransfer) but that are outside of this default task's memory access permissions. Calling sciReceive() ends up with data abort. So either HalCoGen generated source code needs to be modified outside the USER CODE BEGIN - USER CODE END sections or some additional logic needs to be added to the user code, or the user needs to write his own sci driver that does not use HalCoGen global structures or it has to be a privileged task (the last option is not desired of course).

Cheers,

Adam

  • Hi Adam,

    I am not freeRTOS person. I know that switching the task to privilege is not a good option for you. Can you try to use Queue to exchange information between the tasks?

    1. In SCI iSR, send the global variable (g_sciTransfer) to a pre-created Queue using xQueueSendToBackFromISR() API
    2. Your task reads the variable from the Queue using xQueueReceive() API
  • Maybe I should wait some more time for someone who has some experience with the FreeRTOS-MPU/HalCoGen/Hercules mix.
  • Hi Adam,

    You can write a simple function to receive byte using interrupt mode, but not using the global variable which is used to define the data length.
  • QJ Wang said:
    Hi Adam,

    You can write a simple function to receive byte using interrupt mode, but not using the global variable which is used to define the data length.

    So the suggestion is basically to write my own SCI driver function instead of using HalCoGen generated one? Then it would be great if HalCoGen team take such issues into account and make HalCoGen more FreeRTOS-MPU friendly in the next releases.

  • Hello Ritchie,

    The HALCOGen generates the basic low level HW drivers, and you can modify the code for your application. I will feedback your suggestion to HALCogen developers.