0

I am using Aurix Tricore TC27x board. Here I am using two interrupts, one interrupt will occur for every 5us(High Priority) and another interrupt will occur for every 100us(Low Priority). The time for executing the 100us(Low Priority) interrupt is 40us, so while executing the 100us(Low Priority) interrupt if 5us(High Priority) interrupt comes context switching is not happening.

After completing the Low priority interrupt then only switching is happening to High Priority interrupt. Because of this I lost data.

Why it is not preempted?

Thanks in Advance.

kishore
  • 1
  • 1
  • 1
    Usually, you have to re-enable interrutps in a handler to allow higher-priority interrupts to preempt. This allows the lower-priority interrupt to get vital 'must not be interrupted' work out of the way before allowing preemption. An example is when the low-priority handler needs to first get a buffer pointer from a queue before loading it from some device. If it got interrupted early while manipulating the queue ,the high-prio handler may also get a buffer pointer and so corrupt the queue indexes. – Martin James Apr 26 '18 at 10:54

2 Answers2

0

try using the __bisr(IPRN) when installing the interrupt handler, this will allow high priority interrupts to interrupt lower priority interrupts. Im not sure if this is included with all compilers but is definitely available with the tasking compiler.

0

As Martin James already mentioned in his comment and Steve Mitchell in his answer, you need to re-enable interrupts in the ISR. In TASKING Compiler, this is done a bit more intuitively with the __enable_ statement in the function definition:

void __interrupt(YOUR_INT_PRIO) __vector_table(YOUR_INT_PROVIDER) __enable_ name_of_your_isr (void)
{
   /* this ISR may be interrupted */
   /* your code here */
}

If you don't use the __enable_ statement, the ISR can't be interrupted, even if it has a lower priority than a more recent priority. After finishing the ISR, the IRQ with the highest priority (=highest number) of all pending IQRs is served.

void __interrupt(YOUR_INT_PRIO) __vector_table(YOUR_INT_PROVIDER) name_of_your_isr (void)
{
   /* this ISR will NOT be interrupted */
   /* your code here */
}

For other compilers read the user manual of your compiler or have a look at the "TriCore TC1.6P & TC1.6E Core Architecture User Manual" from Infineon in the section about the Interrupt System.

Matthias Luh
  • 503
  • 6
  • 11