STMicroelectronics AN1712 Generating High Resolution Sinewave Using ST7 PWMART

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.


STMicroelectronics AN1712 Generating High Resolution Sinewave Using ST7 PWMART - cover page
Brand
STMicroelectronics
Category
microcontrollers
Document type
Application Note
Language
English
Pages
14
File format
PDF
File size
106 KB
Published
07 August, 2012
Updated
29 September, 2023
Model
ST7
MD5 checksum
784679E70A18B4C4662082D10ABD0D41

About this manual

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.

What's inside

  • Introduction
  • Generating a Sinusoid
  • PWM Generation
  • Sinewave Generation
  • Improving Sinewave Resolution
  • Software Configuration
  • Sin Structure Initialization
  • Auto-Reload Timer Initialization
  • Software
  • Low Pass Filter

Specifications

PWMART Counter Bits8-bit
PWMART Prescaler Bits7-bit
Minimum Samples for <5% THD18
Microcontroller ExampleST72321J9

Frequently asked questions

What is the minimum number of samples needed for a sinewave with less than 5% THD?

More than 18 samples in a sinewave cycle should be selected to generate a sinewave with Total Harmonic Distortion of less than 5%.

What is the minimum number of samples required in a sinewave cycle to keep Total Harmonic Distortion below 5%?

More than 18 samples in a sinewave cycle should be selected to generate a sinewave with Total Harmonic Distortion of less than 5%.

What is the resolution of the sinewave frequency when using the predefined initialization values for frequencies between 45 and 65Hz?

The resolution is less than 0.1Hz for sinewave frequencies from 45 to 65Hz.

What is the maximum average minimum sinewave frequency achievable in the example calculation on page 5?

The maximum average minimum frequency is 500 Hz.

Download PDF (106 KB)

More STMicroelectronics Manuals


View all STMicroelectronics manuals →