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.

am243x Timer interrupt priority

Hi,

I'm using the am243x-EVM with tcp server example.

I set a timer to give semaphore and wake free rtos task.

I have the following line in FreeRTOSConfig.h #define configMAX_SYSCALL_INTERRUPT_PRIORITY    (0xE0U)

What should be the timer interrupt priority in (syscfg) so it will be lower than free rtos - so the task can awake ?  (allowed range is 0-15)

Thanks,

Eli

  • Hi Eli,

    Since the system tick for FreeRTOS is using TIMER8 and it is set to interrupt priority 15 (lowest), so I would recommend 15 for your customized timer interrupt priority.

    Best regards,

    Ming

  • Hi Ming,

    I put the Timer interrupt  to 15  but still task awakes in ~ 20usec instead of ~2usec

    I 've tested a simple program with FreeRTOS task and timer interrupt callback.

    SemaphoreHandle_t sem=NULL;

    sem = xSemaphoreCreateBinary();

    //----------------------------------------------------------------------------------------------------------

    void Task(void)
    {
       while(1)
         {
          if(xSemaphoreTake(sem,0xFFFFFFFF));
           {

            do_something();    //<--------POINT B

            }

        }//forever
    }//Task
    //----------------------------------------------------------------------------------------------------------------------------------------------------------

    void TimerTick(void)
    {
    BaseType_t xHigherPriorityTaskWoken = pdFALSE;
    xSemaphoreGiveFromISR(sem, &xHigherPriorityTaskWoken);
    portYIELD_FROM_ISR(xHigherPriorityTaskWoken);//request a context switch   //<<----------------POINT A

    }//TimerTick

    //-------------------------------------------------------------------------------------

    The TimerTick() works as expected every 31.24usec !  (measured with oscilloscope) 

    I measure  from point A to point B , time = ~ 20usec.

    What should I configure to get max 2usec latency ?

    Thanks,

    Best Regards,

    Eli

     

  • Hi Eli,

    The only thing I can think of is the priority of your Task() where the xSemaphoreTake() is waiting. In general, the task scheduling happens every 1000us or there is an interrupt happening. The task scheduler will put the highest task in execution. If there is a task has higher priority than the Task(), then the execution of the xSemaphoreTake() will be delayed. Please check the priorities of all the tasks in your example, including the idle task. Make sure your Task() is in the highest priority.

    Best regards,

    Ming

  • Hi Ming,

    I've checked the Task() priority it s the highest among other FreeRTOS tasks - 30/32.

    The Timer interrupt priority tryed 0 , 5, 15.

    In FreeRTOS Config.h  interrupt priority  tryed 0xE0 - original then 32 then 20.

    On all cases I have a jitter on Task awekening ranging from 3usec - 40usec.

    I've followed the disassembly of the TimerTick() interrupt it seems very long - Is there a way to shorten it - to a faster interrupt ?

    Thanks,

    Best Regards,

    Eli

  • Hi Eli,

    The TimerTick() function is implemented in the FreeRTOS port in DPL. There is no easy way to shorten it. You can try the same experiment with NORTOS. If it is shorter, then it is caused by the FreeRTOS porting. If that is the case, we can file a JIRA ticket against the MCU+ SDK.

    Best regards,

    Ming

  • Hi Ming,

    I put the timer interrupt priority to 15,

    configMAX_SYSCALL_INTERRUPT_PRIORITY (10) 
    configKERNEL_INTERRUPT_PRIORITY (0)
    configMAX_API_CALL_INTERRUPT_PRIORITY (0) 

    The FreeRTOS task is at 30/32 - the highest

    From interrupt to task awakening I get 2-25usec. My real time limit is ~3usec !

    Please advice.

    Thanks,

    Best regards,

    Eli

     

  • Hi Eli,

    I think the solution we provided in the following thread answered you question:

    (+) LP-AM243: [Servotronix\MIDEA] - Arm-based microcontrollers - INTERNAL forum - Arm-based microcontrollers - INTERNAL - TI E2E support forums

    My number is less than 2us even in the worst case, unless you have more interrupts to handle in your application.

    The priority for an interrupt has nothing to do with the task priority, because the interrupt handling is always higher than a task execution.

    Best regards,

    Ming

  • Hi Ming,

    I can not reach this page, can you please send me another link.

    When I measure once I also get 2usec but when I measure 100 times , 30-40% of the times I get 25usecs.

    I've also noticed that if at the freeRTOS task I put disable interrupts - it has no effect.

    I suspect that the interrupt controller is not properly initialized ( this is tcp server example)

    Thanks,

    Best Regards,

    Eli

      

  • Hi Eli,

    Sorry, the above link is in internal forum by Eyal Cohen. I think he might have forwarded it to you.

    I think the difference is due to the application we used. I am using the Hello World application while you are using the tcp server example. I will do the same test with the tcp server example and get back to you early next week.

    Best regards,

    Ming

  • Hi Ming,

    Yes please do.

    Thanks,

    Best Regards,

    Eli

  • Hi Eli,

    Sure!

    Ming

  • Hi Eli,

    Here is what I got from the tcp server example:

    The max latency is 1.8us over 187 times. It is still under 2us, but I can also see where the problem might be. In my case, the TCP server is waiting for the network to be up. (printing "Waiting for network UP ..." continuously). I think once the network is up, there will be more interrupts to serve and more higer priority tasks to run. All those can affect the latency (both maximum and the average latency) in two different ways:

    1. the execution of ISR for the internet related interrupts

    2. the higher priority tasks (has higher priorities than the task runs the "xSemaphoreTake( gSem, portMAX_DELAY)".

    In conclusion, the latency is really depending on the application environment. The higher the network traffic, higher the latency; The lower the task priority which runs the "xSemaphoreTake( gSem, portMAX_DELAY)", higher the latency.

    You really cannot do too much to reduce the latency introduced by the item 1. However, you can increase the priority of the task which runs the "xSemaphoreTake( gSem, portMAX_DELAY)" to reduce the latency.

    One more thing, please build your CCS project using Release profile, if you have not done that yet.

    Best regards,

    Ming  

  • Hi Ming,

    I'll repeat same test at my EVM and try to improve the latency.

    Thanks,

    Best Regards,

    Eli