This application note presents a software technique for generating a high resolution sine wave using ST7 PWMART. The frequency and average amplitude of the sine wave can be adjusted, and the implementation uses the ST72321J9 microcontroller. PWMART is used to generate a PWM signal, which is then filtered by a low pass filter (a simple RC circuit) to generate the sine wave.
This document presents a software technique for generating a high-resolution sinewave using the ST7 PWMART (Auto-reload timer peripheral) embedded in the ST72321J9 microcontroller. The method involves generating a PWM signal and filtering it with a low-pass RC circuit to produce a sinusoid. The note details the hardware configuration of the PWMART, including the 8-bit auto-reload counter and 7-bit clock prescaler.
The application explains how to configure the PWMART to generate a sinewave by adjusting the number of samples per cycle, the counter reload value (ARTARR), and the duty cycle. It provides specific software initialization steps, including setting up the ARTARR register, enabling the timer counter, and configuring the PWM control register. The document also includes a header file structure for defining sinewave patterns and notes that the provided source code is for guidance only.
| PWMART Counter Bits | 8-bit |
|---|---|
| PWMART Prescaler Bits | 7-bit |
| Minimum Samples for <5% THD | 18 |
| Microcontroller Example | ST72321J9 |
More than 18 samples in a sinewave cycle should be selected to generate a sinewave with Total Harmonic Distortion of less than 5%.
More than 18 samples in a sinewave cycle should be selected to generate a sinewave with Total Harmonic Distortion of less than 5%.
The resolution is less than 0.1Hz for sinewave frequencies from 45 to 65Hz.
The maximum average minimum frequency is 500 Hz.