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.

FreeRTOS on Hercules LaunchPad, HALCoGen 3.06.00, Timers

Other Parts Discussed in Thread: HALCOGEN

Hi folks-

I have been playing with the new Hercules LaunchPad TMS570 for a few days now and I'm running into a snag with FreeRTOS.

I am writing a device driver for an SPI-based LCD display, and part of the initialization routine involves doing a mandatory 100ms wait before issuing any SPI commands to its controller.  To implement this, I would like to use the FreeRTOS Timer subsystem.  This appears to be fairly straightforward and since I am only using this timer once, I am allocating it from within the task using xTimerCreate(), running it with a callback function & volatile flag variable, then deleting it.

Apparently though, issuing xTimerCreate() from within a FreeRTOS task produces a PABT (prefetch abort) exception.  While I am not fully versed yet on the MPU subsystem and how FreeRTOS interacts with it, one thing I've found surfing the source code produced by HALCoGen is that most of the task & queue-related operation functions are "wrapped" using MPU_* function names; os_mpu_wrappers.h has these details.

But none of the Timer-related functions are wrapped.  Yet in os_timer.h, you see the PRIVILEGED_FUNCTION keyword next to some of the function prototypes, including xTimerCreate:

xTimerHandle xTimerCreate( const signed char * const pcTimerName, portTickType xTimerPeriodInTicks, unsigned portBASE_TYPE uxAutoReload, void * pvTimerID, t
mrTIMER_CALLBACK pxCallbackFunction ) PRIVILEGED_FUNCTION;

So is this a bug or omission on HALCoGen's part, a bug on FreeRTOS's part, or neither?  Is it a known issue?  Seems like the obvious way to get around this is to allocate the resource in main() before the task scheduler starts.

  • Eric,

    I need to contact our Halcogen team to check with them. I will be back with shortly.

  • Fyi- I went ahead and manually added MPU_* calls for the necessary Timer functions (in os_mpu_wrappers.c) and updated os_mpu_wrappers.h.  Also included MPU_vQueueDelete() which was missing (see http://sourceforge.net/tracker/?func=detail&aid=3541573&group_id=111543&atid=659633 ... this was fixed upstream over a year ago).

    The result is two modified files that I need to re-copy over the source tree every time I run Generate Code inside halcogen.

    Source here: http://spirilis.net/junk/hercules/os_mpu_wrappers_08142013_halcogen030600.zip

    Alas, these issues should be fixed inside HALCoGen for future use of FreeRTOS.

  • Hi Eric,

    Sorry for the inconvenience

    I am not freeRTOS expert but i see that MPU_vQueueDelete() has to be added, we will take care of it.
    Until freertos v 7.4.0 MPU wrapper does not include Timer functions, hence when we ported we did not add them in HALCoGen.
    I am not sure why Timers are left unwrapped, Just for my understanding, why can't your Task be a Privilege Task incase you are using Timer?

    Regards
    Prathap

  • Hi Prathap-

    Thanks for the explanation, if Timer MPU support wasn't included upstream then that explains things.

    As far as privileged tasks go, I am not doing anything specific to elevate my tasks but I do have a checkbox marked in HALCoGen's OS tab -- "Run All Tasks in System Mode".  Is this the same thing?  I've had this enabled on all my FreeRTOS projects so far but they still need the MPU_* functions present for Timer support.

  • Hi Eric,

    "Run All Tasks in System Mode" checkbox in HALCoGen is no more used ever since a paramemter added in the create task function to choose the privilege or User mode.

    Regards
    Prathap

  • Thanks, I see that now in the HALCoGen help for xTaskCreate ... portPRIVILEGE_BIT.  I'll give that a spin.