Interrupt stops scheduler – FreeRTOS 5.3.0

Hi all, I’m running freertos on AT91SAM7S64. I run a system with few tasks (no interrupts yet): reading keypresses, using 1x16lcd, led blinking.
Now I want to add RTT, so interrupt has to be involved. Because I use GCC I use wrapper, and ‘naked’ all fine.
So, I let the system to run for ~10sec, all tasks switch ok, and when first RTT interrupt trings, the system stops switching tasks. But it does not crash. Last system settings are visible e.g. text on LCD, and RTT interrupt is working as programmed: it triggs every 1sec, and blinks LED. So my guess is that somehow my RTT irq disables the scheduler, how do I fix this?

Interrupt stops scheduler – FreeRTOS 5.3.0

I would guess (and it is a guess) that the RTT interrupt is not being cleared correctly.  It has to be cleared in both the RTT itself and also to AIC. Does the RTT share the system interrupt, or does it have its own interrupt vector? Regards.

Interrupt stops scheduler – FreeRTOS 5.3.0

That was helpful. RTT wasn’t cleared properly, because it shared interrupt with SYS. So now I have modified SYS interrupt so that RTT is checked.
However, now system reboots randomly if I serve RTT in SYS irq without any function calls. If I do call a function that serves RTT then I get a data_abort. As I said I use GCC, but no preemption, so do I have to SAVE and RESTORE context?
What bad can happen when other interrupt shares vector with SYS?

Interrupt stops scheduler – FreeRTOS 5.3.0

Search far back in this forum, there have been threads on sharing the system interrupt before.

Interrupt stops scheduler – FreeRTOS 5.3.0

I did search back, and a suggestion was made to add a ‘dispacher’ but in freertos 6.0 shared interrupts for SYS are still not supported.

Interrupt stops scheduler – FreeRTOS 5.3.0

OK that is the thread I’ve found . All fine and I’ve done the same, but I’m still gettings random crashes. This is modified portISR: void vNonPreemptiveTick( void ) { unsigned portLONG ulDummy; /* Increment the tick count – which may wake some tasks but as the preemptive scheduler is not being used any woken task is not given processor time no matter what its priority. */                 if (0 != (AT91C_BASE_PITC->PITC_PISR & AT91C_PITC_PITS))
                  {
                    vTaskIncrementTick();                     ulDummy = AT91C_BASE_PITC->PITC_PIVR;                   }
                if (0 != (AT91C_BASE_RTTC->RTTC_RTSR & AT91C_RTTC_RTTINC))
                  {
    ulDummy = AT91C_BASE_RTTC->RTTC_RTSR;
                    ulDummy = AT91C_BASE_RTTC->RTTC_RTVR;
                  }
/* End the interrupt in the AIC. */ AT91C_BASE_AIC->AIC_EOICR = 0; } `
The only difference is that I’m using non preemptive kernel.   : http://sourceforge.net/projects/freertos/forums/forum/382005/topic/1351935

Interrupt stops scheduler – FreeRTOS 5.3.0

Found the problem – spurious interrupt. For whatever reason PIT and RTT together where causing spurious irqs. In pvrSetupTimerInterrupt() I have added`        AT91C_BASE_AIC->AIC_SPU = AT91C_BASE_AIC->AIC_SVR;`
And that fixed the problem. I will change this to specific spurious irq handler, but for time being it does the job – system does not crash at all.

Interrupt stops scheduler – FreeRTOS 5.3.0

Out of interest, what did you set you default handler to? In the end I created my own..
__irq __arm void
AT91F_Spurious_handler(void)
{
   AT91F_AIC_AcknowledgeIt(AT91C_BASE_AIC);
   return;
} (For IAR). but I’m not sure how to test it.. or if it is going to upset FreeRTOS.. Found the following, but can’t see how the provided solution works.. (no __irq keyword..)
http://www.at91.com/forum/viewtopic.php/f,15/t,3180/
(Title: “Odd interrupt enabling / disabling issues causing chip reset”)