Configure a timer to PWM mode with the following sequence:
- Ensure the timer is disabled (clear the TnEN bit) before making any changes.
- Write the GPTM Configuration register (GPT:CFG) with a value of 0x0000 0004.
- In the GPTM Timer Mode register (GPT:TnMR), write the TnCMR field to 0x1 and write the TnMR field to 0x2.
- Configure the output state of the PWM signal (whether or not it is inverted) in the GPTM Control register (GPT:CTL) TnPWML field.
- If a prescaler is to be used, write the prescale value to the GPTM Timer n Prescale register (GPT:TnPR).
- If PWM interrupts are used, configure the interrupt condition in the GPT:CTL TnEVENT register field, and enable the interrupts by setting the GPT:TnMR TnPWMIE register bit.
- Load the timer start value into the GPTM Timer n Interval Load register (GPT:TnILR).
- Load the GPTM Timer n Match register (GPT:TnMATCHR) with the match value.
- Set the GPTM Control register (GPT:CTL) TnEN bit to enable the timer and begin generation of the output PWM signal.
In PWM timing mode, the timer continues to run after the PWM signal is generated. The PWM period can be adjusted at any time by writing the GPT:TnILR register, and the change takes effect at the next cycle after the write.