Periodic Interrupt Timer and Real Time Interrupt (PIT_RTI)
MPC5510 Microcontroller Family Reference Manual, Rev. 1
28-12
Freescale Semiconductor
Preliminary
To generate the interrupt, the interrupt line must be enabled by writing a 1 to the RTIE bit in the PITINTEN
register. There is no need to modify PITINTSEL because the RTI timer is always used for interrupts and
never for trigger events. To start the RTI, PEN0 in the PIT timer enable register 0 (PITEN0) is set.
The interrupt for timer 1 is enabled by setting TIE1 in the PITINTEN register and the interrupt/DMA
selector ISEL1 (in PITINTSEL) is set to 1. The timer is started by writing a 1 to bit PEN1 in the PITEN
register.
Timer 8 will be used for triggering only. Timer 8 is started by writing a 1 to bit PEN8 in the PITEN register.
It is also possible to set up all timers and start them simultaneously by writing to the PITEN register.
However the RTI still cannot start in synchronization because it is running on a separate clock.
The following example code matches the described setup:
// turn on PIT
PIT_REG_P->pit_CTRL = 0x00;
// RTI
CRG_REG_P->crg_CTL |= 1<<2; // Set RTI bit in CLKSEL
PIT_REG_P->pit_TLVAL0 = 0x004C4B3F; // setup RTI for 5000000 cycles
PIT_REG_P->pit_INTEN = 0x00000001; // let RTI generate interrupts
// writing INTSEL is unnecessary
PIT_REG_P->pit_EN |= 1<<0; // start RTI
// Timer 1
PIT_REG_P->pit_TLVAL1 = 0x0003E7FF; // setup timer 1 for 256000 cycles
PIT_REG_P->pit_INTEN |= 1<<1; // enable Timer 1 interrupts
PIT_REG_P->pit_INTSEL |= 1<<1; // select Timer 1 for interrupts
PIT_REG_P->pit_EN |= 1<<1; // start timer 1
// Timer 8
PIT_REG_P->pit_TLVAL8 = 0x0016E35F; // setup timer 8 for 1500000 cycles
// timer 8 can’t generate interrupts -> no settings needed for trigger
PIT_REG_P->pit_EN |= 1<<8; // start timer 8