![Freescale Semiconductor QE128 Quick Reference User Manual Download Page 111](http://html1.mh-extra.com/html/freescale-semiconductor/qe128/qe128_quick-reference-user-manual_2330661111.webp)
Using the Output Compare function with the Timer/Pulse-Width Modulator (TPM) module for the QE Microcontrollers
QE128 Quick Reference User Guide, Rev. 1.0
Freescale Semiconductor
13-3
This is the main function, here are called the functions described above and all the interrupts are enable.
after this the TPM interrupt can be detected.
void main(void) {
MCU_Init(); // Function that initializes the MCU
GPIO_Init(); // Function that initializes the Ports of the MCU
TPM_Init(); // Function that initializes the TPM module
EnableInterrupts; // enable interrupts
for(;;) {
} // loop forever
// please make sure that you never leave this function
}
NOTE
This is the Timer-Pulse Width Modulator service routine. Every time an
TPM interrupt is detected, the PTE0 pin is toggle. The interrupt will be
generated when the counter counts up to 0xFFFF, after whis an interrupt will
be generated and detected by the MCU.
void interrupt VectorNumber_Vtpm3ch3 TPM_ISR(void) {
// TPM interrupt vector number = 28 (S08)
// TPM interrupt vector number = 90 (V1)
TPM3C3SC_CH3F; // Clears timer flag
TPM3C3SC_CH3F = 0;
PTED_PTED0 = ~PTED_PTED0; // Toggle PTE0
}