Post Go back to editing

"Detecting Execution Context on ADSP-SC58x: Interrupt vs. Task Context"

Category: Software
Product Number: ADSP-SC58x

I'm working with ADSP-SC58x and I'm looking for a way to determine whether the execution is running from an interrupt context or from a task context in the Sharc cores. I'd expect it to be mapped to a bit field in one of the SHARC core registers. Is there a way to do so?

Thread Notes

  • Hi,
    To assist you better please share the details about your application and explain more on your requirements.
    Also, Are you using RTOS in your Application?
  • Hi Ranji,

    Yes I'm using FreeRTOS, which usually provides two versions of the same function, one for task contexts, and another one for ISR contexts.
    What I'm trying to do is to encapsulate this difference into a single API, so that when it's called, there's no need to worry about which version of the function is called. That's why I'm looking for a way to determine the context during runtime.

  • Hi,

    From your query we understood that you want to differentiate how to call the same API from Task handler and Interrupt handler functions.

    FreeRTOS provides two versions of APIs for calling from task and interrupt level. Whenever you want use FreeRTOS API from an ISR, its ISR version must be used. Because being in the interrupt Context (i.e. being in the middle of servicing the ISR) you can not return to Task Context (i.e. making a task to run by
    pre-empting the ISR)

    Task level call:
    FreeRTOS APIs which don’t end with the word “FromISR” are called as interrupt unsafe APIs
    Ex: vTaskResume(),xTaskNotify() etc

    Interrupt level call:
    FreeRTOS APIs that end in "FromISR" are interrupt safe and you can call it from ISR routine.
    EX: xTaskResumeFromISR(), xTaskNotifyFromISR()

    You can get more information about these APIs from the below path

    Hope this helps.

    Best Regards,


  • Hi Santha,

    Thanks for the help.

    Yeah I came across the fact that FreeRTOS provides two versions of the same API. What I'm actually trying to do is something like this:

    void ResumeTask(void){
        if(/*Some condition here ...*/){

    So I'm looking for some way to detect if the program is currently executing in a task context or an interrupt context, and based on this information the appropriate call is to be made.