cancel
Showing results for 
Search instead for 
Did you mean: 

Code Examples

odissey1
Honored Contributor II

Hi,

This is a demo project showing 8-bit Sine (or arbitrary shape) wave generation using custom component (WaveGen) and standard PWM. The wave generator is RAM-DMA-PWM bridge transferring 8-bit data from RAM buffer to PWM. The PWM period is set to 255 to match 8-bit incoming data. Sine wave frequency is controlled with high resolution by the DDS32 generator.

The demo project provides examples of 32 and 256 wave points/period. External RC-filtering of the PWM output needed to produce a smooth sine wave. Like with all PWM-generated analog signals, the maximum achievable output frequency is quite limited. The upper frequency for this design is limited by the maximum DDS output frequency (BUS_CLK/2). For example, using 32 samples/period, Fmax = (BUS_CLK/2) / ( 256 x 32) = 2.9 kHz.

Draft version of the WaveGen component is included in the project. The DDS32 component can be found here:

Re: DDS24: 24-bit DDS arbitrary frequency generator component

/odissey1

Figure 1. Sine wave production using RAM-DMA-PWM bridge (WaveGen) and DDS32.

WaveGen_PWM_02a_basic_A.png

Figure 2. Yellow trace - PWM output at 32 points/period, Cyan trace - WaveGen reference signal.

WaveGen_PWM_02a_basic_cA.png

1 Reply
Roy_Liu
Moderator
Moderator

Thanks for the sharing.

Roy Liu
0 Likes