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.

CC2340R5: How is 'timer_settime' function is a blocking function in "TI-POSIX" even though it shows the ability to be used inside ISR in implementation ?

Part Number: CC2340R5

Tool/software:

It's my first time dealing with TI MCUs, I decided to go with TI-POSIX which is just a wrapper for freeRTOS. However it shows on their user guide for "TI-POSIX" that the function called "timer_settime" is a blocking function where they stated and I quote 

timer_settime() - this is a blocking call, unlike on TI-RTOS

where the only functions the can be used inside in ISR are the following functions:

However, looking inside the implementation of the "timer_settime" function, we can clearly see the following lines:

    if (HwiP_inISR())
    {
        status = xTimerChangePeriodFromISR(timer->xTimer, timeoutTicks, &xHigherPriorityTaskWoken);
    }
    else
    {
        status = xTimerChangePeriod(timer->xTimer, timeoutTicks, (TickType_t)-1);
    }

which checks if we are inside ISR or not which contradicts the documentation. does this mean that there are functions that I can use inside an ISR?

  • Hi Abdelrahman,

    Did you intentionally refer to the 7.10 version of the SimpleLink F3 SDK documentation in your link?  Here is the 8.40 version which is the latest, although it does not change any of the content you are inquiring about.

    My interpretation is that since timer_settime will block, and since hardware interrupts should always run to completion and not be blocked, then the code you're referring to in timer_settime is evaluating whether the function was called in an ISR (true) or at thread level (false), as it will need to act accordingly.  Although this may work around non-blocking HWI requirements, my recommendation would be to use semaphores and event flags to quickly leave the HWI ISR context and further process the application within a thread context.  Please review the Thread synchronization section of stack User Guide documentation to better understand what I am talking about.

    Regards,
    Ryan