This application note describes how to use the ST62 Auto-reload Timer (ARTimer) to generate a PWM signal with tunable frequency and duty cycle. As an example, the generation of a 31.25kHz PWM signal with duty cycle proportional to an analog input voltage is presented.
The document explains the features of the ST62 Auto-reload Timer, an 8-bit timer/counter with prescaler that supports auto-reload PWM generation. It details how to configure registers such as Mode Control (MC), Status (SCO, SC1), Load (LR), Incremental Counter (TC), Compare (CP), and Reload/Capture (RC) to control the output.
| Timer type | 8 bit timer/counter with prescaler |
|---|---|
| PWM frequency range | up to 100kHz |
| Resolution (max) | 1/256 |
| Resolution (alt) | 1/64 |
The PWM frequency (Few) is calculated by dividing the timer input frequency (Fin) by (256 - RC).
The duty cycle is defined by the Compare register CP relative to the Reload register RC and 255.
A resolution of 1/64 is required, which corresponds to a specific prescaler setting.