Hi
So this looks OK, but I can see a couple of places where there may be a mistake:
When you set up the counter, you should first disable it, and then you clear the interrupt flag and set the overwrite flag to 1 like so:
void init_interrupt_timers (void)
{
MCF_INTC1_ICR43 = MCF_INTC_ICR_IL(0x07);
MCF_INTC1_IMRH &= ~MCF_INTC_IMRH_INT_MASK43;
MCF_PIT0_PCSR = 0;
MCF_PIT0_PCSR = MCF_PIT_PCSR_PRE(0x1) |
MCF_PIT_PCSR_PIE |
MCF_PIT_PCSR_PIF | // Clear interrupt flag
MCF_PIT_PCSR_OVW | // Set overwrite flag
MCF_PIT_PCSR_RLD |
MCF_PIT_PCSR_EN;
MCF_PIT0_PMR = MCF_PIT_PMR_PM(0x9c3f);
MCF_PIT1_PCSR = 0;
MCF_PIT2_PCSR = 0;
MCF_PIT3_PCSR = 0;
}
Then I assume you want to make the LED flash? The way that you have configured the PIT you would expect an interrupt every 1ms, but your ISR has two loops which I assume are so that the LED flashes slowly?
This is what happens:
Your PIT timer starts counting.
After 1ms your ISR is called, as you have set the interrupt level to 7 all interrupts at level 7 and below (in other words _all_ interrupts) are masked.
You immediately clear the interrupt, which will start the PIT counter again.
You then switch a LED, wait for some time, switch again and wait. After 1ms, the PIT interrupts again, but all interrupts are masked so no problem, even though this is probably not what you expect.
Why don't you count the number of times that the interrupt occurs, or set the interrupt to occur at a slower frequency:
To get a 1 second flash you could do this:
__interrupt__
void PITimer0_interrupt(void)
{
static uint32 interval = 0;
MCF_PIT0_PMR |= MCF_PIT_PCSR_PIF;
interval++;
if (interval == 1000)
{
MCF_GPIO_PODR_TIMER ^= MCF_GPIO_PODR_TIMER_PODR_TIMER3;
interval = 0;
}
}
Or change the prescaler and modulo to give 1 interrupt every second then you just need this:
Code:
__interrupt__
void PITimer0_interrupt(void)
{
MCF_PIT0_PMR |= MCF_PIT_PCSR_PIF;
MCF_GPIO_PODR_TIMER ^= MCF_GPIO_PODR_TIMER_PODR_TIMER3;
}
Paul