By Krupa Bhavsar Applications Engineer, Dialog Semiconductor
Sine waves are continuous waves, which describe a smooth periodic oscillation. These waves are generally used in signal processing and engineering fields
In this article, double sine waves with opposite polarity as shown in figure 1 are generated without coarse PWM “steps”. To generate sine waves, a PWM macrocell is used. The PWM macrocell has a pre-programmed table with PWM Duty Cycle values for each “step” of the sine wave.

Figure 1. Sine waves with opposite polarity
This project is divided into three sections. The Clock Frequency Generation section describes calculations to generate a new desired sine wave frequency. In the HV PAK section, the circuit design is shown and explained. Finally, the Test Setup and Future Expansion section provides additional details about the testing conditions and other possibilities this project has.
Frequency generation
The generation of the sine wave is divided into 2 parts. The pre-programmed Duty Cycle values of a part of the wave are stored in the Reg file of the PWM macrocell and increase after the arrival of each clock. When the number of clocks is equal to the number of bits in the Reg file, the PWM macrocell state Up/Down input changes and the Reg file starts synchronizing in the opposite direction.
The new generation clock frequency depends on the sine wave frequency. The number of PWM periods required for a sine wave frequency. Equation 1
Where, – desired sine wave frequency, – number of pre-programmed bits, by default is 16.
HVPAK Project
In this project, we use GreenPAK circuit
to illustrate how the sine wave generator can be constructed – specifically SLG47105 High Voltage GreenPAK (HVPAK). The complete circuit design file created in the GreenPAK Designer software (available free of charge) can be found here.
Figure 2 shows the project. This design requires only one external input, i.e. EN input. In this project, the PWM0 macrocell is configured as a frequency-controlled generator that generates PWM signal for each part of a sine wave. The outputs of the PWM0 macrocell are connected to the HV OUT CTRL0 which is then connected to the external filters to obtain double sine waves with reverse polarity.
In this project, the HVPAK project is configured to generate a 1kHz sine wave.
CNT0/DLY0/FSM0 is configured as Reset Counter. The output period CNT0/DLY0/FSM0 determines a period of each step of the Reg file and the frequency of the output sine wave (1).
According to (1) to generate an output sine wave frequency of about 1kHz, the CNT0/DLY0/FSM0 output frequency must be equal to 31.25kHz or output period 32us.
The PWM direction changes every 16s clock period. CNT1/DLY1 counts 16 clock periods of the input signal. The DFF6 is configured as a toggle flip-flop that changes the direction of the PWM macrocell.
The HV OUT CTRL0 macrocell is configured in control configuration in Half-Bridge mode. The PWM0 OUT+ is connected to IN0 and the OUT- output is connected to IN1. Inputs OE0 and OE1 are connected to POR. The suspend inputs are used to disable HV OUT CTRL0 when the EN signal is in the Low state.
A pair of external RC filters are required to smooth PWM signals and receive noise-free sine waves.
The DFF3 flip-flop and 2-bit LUT1 are used to skip the first half of the period after the generator starts. The first channel sine wave starts at 100% duty cycle while the output RC filter is unloaded. In this case, half of the first period of the channel 1 sine wave is completely distorted.
Thus, to generate a sine wave of a desired frequency using a desired input frequency, the designer first calculates the parameters necessary to modify the macrocells as described in the Clock Frequency Generation section, and then modifies the PWM macrocell settings and CNT as described above.
Test configuration and future expansion
This project is tested using external RC filters and a button. The push button is connected to the EN input and each RC filter is connected to the HV outputs of the HV OUT CTRL0 macrocell, as shown in Figure 3. As shown in Figure 4, double sine wave approximations with opposite polarity are generated when the EN input is HIGH.

Figure 3. Test setup
Channel 1 (yellow line/top) – Pin #2 (EN)
Channel 2 (cyan/2nd line) – Sine wave output on pin #7 (TP1)
Channel 3 (magenta/3rd line) – Sine wave output on pin #8 (TP2)

Figure 4. Sine wave outputs
Future possibilities of this project can be expanded to generate sine waves through an I2C enabled MCU instead of a button, change the frequency of the sine wave and also include protection features like current limit/constant current using Current Sensing Comparator and undervoltage blocking (UVLO). This project can also be expanded to generate additional dual sine waves using the HV OUT CTRL 1 macrocell.
Conclusion
The HVPAK design described in this article generates two 1kHz sine wave approximations. The design is easy to use, minimizes costs, saves board space and component count.
Additionally, the circuit we used is very flexible, easy to test, and can accommodate last-minute design changes. Once the design has been modified, a new design file can be programmed into the chip and soldered back onto the board. It also provides project security by locking the project file to limit visibility. By using this design, the user can generate sine waves with the desired frequency using PWM macrocells and a single input.