• AVR Freaks

Hot!Harmony ISR and FreeRTOS Deferred Interrupt Processing Issue

Author
clange
Junior Member
  • Total Posts : 57
  • Reward points : 0
  • Joined: 2012/05/16 14:25:43
  • Location: 0
  • Status: offline
2020/06/05 16:14:04 (permalink)
0

Harmony ISR and FreeRTOS Deferred Interrupt Processing Issue

Hi all
I'm trying to implement a simple deferred interrupt processing example by using a FreeRTOS Direct to Task Notification.  The basic outline I'm trying to use is Example 2.
 
freertos.org/RTOS_Task_Notification_As_Counting_Semaphore.html
 
I've created a timer with an alarm interval using Harmony (including the assembly wrapper) with INT_PRIORITY_LEVEL3.  The interrupt fires as expected.
 
void IntHandlerDrvTmrInstance0(void)
{
    DRV_TMR_Tasks(sysObj.drvTmr0);
    
    BaseType_t xHigherPriorityTaskWoken = pdFALSE; /* Initialised to pdFALSE. */
    configASSERT( xStreaming_TimerHandlerTask != NULL );
    vTaskNotifyGiveFromISR( xStreaming_TimerHandlerTask, &xHigherPriorityTaskWoken );
    portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
}

 
I can step through and view that the task gets unblocked and set to the ready state (after vTaskNotifyGiveFromISR executes).
 
However, the RTOS never switches into the xStreaming_TimerHandlerTask (which has a higher priority at 2, than the other tasks which are priority 1).  It keeps executing the lower priority tasks like nothing ever happened!  Ultimately, the task gets blocked by something and unblocked again during the ISR but never executes.
 
I can't tell if the problem has to do with interrupt priorities, task priorities, or maybe the assembly wrapper Harmony adds to ISRs?
 
For reference:
 
#define configKERNEL_INTERRUPT_PRIORITY 1
configMAX_SYSCALL_INTERRUPT_PRIORITY 3

 
If anyone has any insight, I'd greatly appreciate it!
post edited by clange - 2020/06/05 16:19:37
#1

5 Replies Related Threads

    clange
    Junior Member
    • Total Posts : 57
    • Reward points : 0
    • Joined: 2012/05/16 14:25:43
    • Location: 0
    • Status: offline
    Re: Harmony ISR and FreeRTOS Deferred Interrupt Processing Issue 2020/06/05 17:13:15 (permalink)
    0
    I'm guessing that the assembly wrapper is my issue 
    _IntHandlerDrvTmrInstance0:
        portSAVE_CONTEXT
        la s6, IntHandlerDrvTmrInstance0
        jalr s6
        nop
        portRESTORE_CONTEXT
        .end _IntHandlerDrvTmrInstance0

    Specifically, portRESTORE_CONTEXT might be hijacking the RTOS’ intended operation?

    I can see that my task remains in the “ready” state after portRESTORE_CONTEXT, but the RTOS never switches to the task.
    post edited by clange - 2020/06/05 21:58:20
    #2
    rjc101
    Super Member
    • Total Posts : 133
    • Reward points : 0
    • Joined: 2016/07/08 14:56:34
    • Location: 0
    • Status: offline
    Re: Harmony ISR and FreeRTOS Deferred Interrupt Processing Issue 2020/06/06 02:14:47 (permalink)
    0
    This is the asm code that was generated by Harmony3 in a FreeRTOS project, if that helps at all.
     
     

    .extern UART2_RX_IntHandler
    .section .vector_146,code, keep
    .equ __vector_dispatch_146, IntVectorUART2_RX_IntHandler
    .global __vector_dispatch_146
    .set nomicromips
    .set noreorder
    .set nomips16
    .set noat
    .ent IntVectorUART2_RX_IntHandler
    IntVectorUART2_RX_IntHandler:
    portSAVE_CONTEXT
    la s6, UART2_RX_IntHandler
    jalr s6
    nop
    portRESTORE_CONTEXT
    .end IntVectorUART2_RX_IntHandler

     
    Do other tasks with a higher priority run at all?
    #3
    clange
    Junior Member
    • Total Posts : 57
    • Reward points : 0
    • Joined: 2012/05/16 14:25:43
    • Location: 0
    • Status: offline
    Re: Harmony ISR and FreeRTOS Deferred Interrupt Processing Issue 2020/06/06 09:15:54 (permalink)
    0
    @rjc101
    Thanks for the reference. It looks identical to the Harmony 2.0 ISR wrapper.
     
    Yes, other high-priority tasks run.
    #4
    clange
    Junior Member
    • Total Posts : 57
    • Reward points : 0
    • Joined: 2012/05/16 14:25:43
    • Location: 0
    • Status: offline
    Re: Harmony ISR and FreeRTOS Deferred Interrupt Processing Issue 2020/06/06 09:38:29 (permalink)
    0
    Actually, it looks like the debugger was lying to me.  I set a breakpoint (inside my ISR triggered task) that never got hit.  However, I added code to toggle an LED in the task and it works just fine.  Apparently, the breakpoint was not able to be resolved - even though the debugger showed solid red!
    #5
    rjc101
    Super Member
    • Total Posts : 133
    • Reward points : 0
    • Joined: 2016/07/08 14:56:34
    • Location: 0
    • Status: offline
    Re: Harmony ISR and FreeRTOS Deferred Interrupt Processing Issue 2020/06/06 09:42:31 (permalink)
    0
    I’ve noticed that lately, I tend to only use the debugger for looking at variables and structures to check they are as expected. Plus to catch the occasional hard fault when I’ve don’t something stupid.
    #6
    Jump to:
    © 2020 APG vNext Commercial Version 4.5