Motivation
Many applications such function generators, musical tuners and toys require analog signals. Rather than use a separate DAC, these signals can be achieved with the MSP430 and a lowpass filter (LPF). The latter will be built from external components.
This project conveys how to generate these signals. An 8-bit DAC will generate a 250Hz sine wave, oversampled at 16x.
The sine wave is constructed by using a lookup table and updating the duty cycle of a PWM signal.
Background
The MS430 will be used to generate analog waveforms, either ramp or sine by filtering the PWM outputs through a LPF.
The GUI will be used to:
- Configure each PWM output including duty cycle, signal type and frequency
- Display the waveforms
- Observe the ADC value which corresponds to the outputted waveform
Operation
Looking at Figure 1 below, the duty cycle of the sine-PWM signal varies from one PWM period to the next, whereas the duty cycle of the DC-PWM signal remains fixed.
The formula for the sampling rate/PWM frequency is:
250Hz * 32 samples = 8kHz.
The capacitor is basically averaging the output samples over time.
The CCR0 interrupt is enabled and the ISR updates the PWM duty cycle which is stored in CCR1.
CCR2 is loaded with a fixed PWM duty cycle to generate the DC signal.
CCR1 is connected to Pins P1.1/TA0.1
CCR2 is connected to P1.2/TA0.2
The 2-pole RC filter removes the higher-order harmonics, leaving a nice analog waveform.
The filtered analog waveform is depicted in figure 4 below:
If R_1*C_1 = R_2 * C_2 = RC, then
f_c = \frac{1}{2 \pi R C}
The cutoff frequency is set to be 795Hz. A higher order filter can be built.
The DC level signal can be altered by varying the duty cycle of the DC PWM signal.
V_DC = D * VCC
Where D = duty cycle of the PWM signal.
The GUI
The GUI provides an interface to adjust the type of signal the user wishes to generate as well as the duty cycle.





