Maybe because I didn't quite understand how that works!
Remember that for a 5MHz clock on a GPIO port that needs to be toggled every 100ns or every ten processor cycles. If by using the match registers I can do that w/o consuming processor cycles, I am all ears!!!
Please could you help me with some example code.
The code I used looked like:
void TIMER1_IRQHandler (void)
{
if((LPC_TIM1->IR & 0x01) == 0x01) // if MR0 interrupt
{
LPC_TIM1->IR |= (1 << 0); // Clear MR1 interrupt flag
if (enablePGC)
{
LPC_GPIO0->FIOPIN ^= PGC; // Toggle PGC (programming clock)
}
else LPC_GPIO0->FIOPIN &= ~(PGC);// Force PGC low
}
}
LPC_SC->PCONP |= 1 << 1; // Power up Timer 1
LPC_SC->PCONP |= 1 << 22; // Power up Timer 2
LPC_SC->PCLKSEL0 |= 1 << 4; // Clock for Timer 1 = CCLK
LPC_SC->PCLKSEL1 |= 1 << 12; // Clock for Timer 2 = CCLK
LPC_TIM1->MR0 = 10; // 5MHz
LPC_TIM1->MCR |= (1 << 0) | (1 << 1); // Interrupt and Reset on MR0
// Reset Timers 1 and 2
LPC_TIM1->TCR = 0x02;
LPC_TIM1->TCR = 0x00;
LPC_TIM2->TCR = 0x02;
LPC_TIM2->TCR = 0x00;
// Clear pending interrupts for Timer 1 and enable timer interrupts
NVIC_ClearPendingIRQ(TIMER1_IRQn);
NVIC_EnableIRQ(TIMER1_IRQn); // Enable timer interrupt
LPC_TIM1->TCR |= 1 << 0; // Start timer 1
If you could show me how to do that using the match stuff I'd be most grateful - I got quite confused reading about EMR and MAT0.n registers