
Originally Posted by
cmason
Have you looked at the periodic interrupt timer (PIT) section of the datasheet?
I was hoping to avoid that, and just work with an existing library, because it always seems to take more time with the datasheet 
I've got it working right now. Here's snippets of my code:
Code:
#define TIE 0x2
#define TEN 0x1
//Turn on interrupts:
SIM_SCGC6 |= SIM_SCGC6_PIT;
// turn on PIT
PIT_MCR = 0x00;
NVIC_ENABLE_IRQ(IRQ_PIT_CH2);
PIT_LDVAL2 = period; // setup timer 2 for period cycles
PIT_TCTRL2 = TIE; // enable Timer 2 interrupts
PIT_TCTRL2 |= TEN; // start Timer 2
PIT_TFLG2 |= 1;
//Turn off interrupts:
PIT_TCTRL2 = 0; // disable Timer 2 interrupts
And the interrupt routine itself:
Code:
extern "C"
{
void pit2_isr(void)
{
..........
PIT_TFLG2 = 1;
}
}