Hi,friends!
I've watched the example code ,and the main function as follows:
void main (void) { | |||
vuint32_t i = 0; | /* Dummy idle counter */ |
initModesAndClock(); /* MPC56xxP/B/S: Initialize mode entries, set sysclk = 64 MHz*/
disableWatchdog(); /* Disable watchdog */
initIrqVectors(); | /* Initialize exceptions: only need to load IVPR */ | ||
initINTC(); | /* Initialize INTC for software vector mode */ | ||
initPIT(); | /* Initialize PIT1 for 1KHz IRQ, priority 2 */ | ||
initSwIrq4(); | /* Initialize software interrupt 4 */ | ||
enableIrq(); | /* Ensure INTC current prority=0 & enable IRQ */ |
while (1)
{
i++; | |
} |
}
void Pit1ISR(void) {
Pit1Ctr++; /* Increment interrupt counter */
if ((Pit1Ctr & 1)==0) { /* If PIT1Ctr is even*/
INTC.SSCIR[4].R = 2; /* then nvoke software interrupt 4 */
}
PIT.CH[1].TFLG.B.TIF = 1; /* CLear PIT 1 flag by writing 1 */
}
void SwIrq4ISR(void) {
SWirq4Ctr++; /* Increment interrupt counter */
INTC.SSCIR[4].R = 1; /* Clear channel's flag */
}
So,I want to know when does MPC5604P enter the function Pit1ISR and SwIrq4ISR ? If I want to light a led when an interrupy happens,where should I add code "SIU.GPDO[52].B.PDO = 0"?
Hi,
as I can see in the code, Pit1ISR should be triggered each 1ms. Each even Pit1ISR should then trigger software interrupt SwIrq4ISR - that means this one will be triggered each 2ms. Now it depends what you want to do... Just toggle GPIOs in both interrupt handlers, connect oscilloscope to GPIOs and watch the result...
Regards,
Lukas