Hello,
I am having an issue with prioritization of two interrupts. The higher priority interrupt is being delayed by the lower priority interrupt. I have included the code below. Hopefully someone can point out my mistake. One interrupt is on a PIT timer that we call the Real Time (RT) interrupt. It simply increments a counter and toggles an LED on/off periodically. The other interrupt (Serial Data - SD) is triggered on the falling edge of a GPIO pin. It is critical that when the SD interrupt triggers, that we interrupt to grab data from other pins. This is not happening. If the RT Interrupt is processing, and the SD interrupt triggers, it is delayed until the RT interrupt completes.
I'll post code below. That interrupt routines are just contain demonstration code. They do simple LED toggles and we added delays so our oscilloscope could catch them.
I'll try to emphasize this issue below using 0's and 1's. The SD interrupt should trigger uniformly. The RT interrupt should not delay the SD interrupt.
RT 00000000111100000000111100000000111100000000
SD 01010101000101010010000010101010000010101010
If anyone can shed some light on this, it would be very helpful. Oh, We are using the Kinetis K64F BTW.
**********************************************************
RT interrupt code:
PIT_SETUP pit3_setup;
pit3_setup.int_type = PIT_INTERRUPT;
pit3_setup.int_handler = RealTimeInterrupt;
pit3_setup.int_priority = 11;
pit3_setup.ucPIT = 3; // use PIT channel 3
pit3_setup.mode = PIT_PERIODIC; // periodic PIT interrupt
pit3_setup.count_delay = PIT_MS_DELAY(10); // 10 ms delay
fnConfigureInterrupt((void *)&pit3_setup); // enter interrupt for PIT3
void RealTimeInterrupt( void )
{
char a[10000];
short i;
GreenLED( ON );
// This is a small delay (approx 2.5 msec) for the oscilloscope to work properly!
for( i = 0; i < 10000; i++ ) {
a = 0;
}
GreenLED( OFF );
}
****************************************************************
SD interrupt code:
INTERRUPT_SETUP SD_Interrupt_setup;
SD_Interrupt_setup.int_priority = 10;
SD_Interrupt_setup.int_port = PORTC;
SD_Interrupt_setup.int_port_bits = PORTC_BIT2;
SD_Interrupt_setup.int_port_sense = IRQ_FALLING_EDGE;
SD_Interrupt_setup.int_handler = BOARD_INTREQ_IRQ_HANDLER;
fnConfigureInterrupt( (void *)&SD_Interrupt_setup );
void BOARD_INTREQ_IRQ_HANDLER( void )
void SerialDataInterrupt( void )
{
BlueLED(ON);
char a[10000];
short i;
for( i = 0; i < 1000; i++ ) {
a = 0;
}
BlueLED(OFF);
}