SPRUIR8B april 2020 – july 2023
The objective of this example is to prevent simultaneous high or low outputs on a PWM pair. PWM modules 1 and 2 are configured to generate identical waveforms based on a fixed frequency up-count mode. The time-base of PWM2 is synchronized to that of PWM1 as shown in Figure 4-2.
The PWM waveforms are generated to deliberately force both outputs in each module to be simultaneously high and low at different times, as shown in Figure 4-3.
The intention is to modify these waveforms with the CLB to remove either simultaneous high or simultaneous low conditions. This represents a simple combinatorial logic example. The logic operates in three modes: normal, active high, and active low. In normal mode, the PWM signals are passed through the CLB un-modified. In active high mode, the logic prevents logical ‘1’ outputs from simultaneously appearing at the PWM pins. Similarly, in active low mode, logical ‘0’ outputs must not appear on both PWM pins. For instance, if the logic is in active low mode and both PWM signals are low, the output for both PWMs will be forced high. Refer to Table 4-2 for more details. The mode is selected using a 2-bit field as shown in Table 4-1.
Mode Name | Type | [MODE 1] | [MODE 0] |
---|---|---|---|
M0 | Normal | 0 | 0 |
M1 | Active Low | 0 | 1 |
M2 | Active High | 1 | 0 |
M3 | Reserved | 1 | 1 |
The logic circuit which implements the patterns is shown in Figure 4-4. Output signals have “_m” appended to the name to indicate they may have been modified by the CLB.
The logic above can be implemented using two 4-input LUTs: one for each output signal. Therefore, only a small part of one CLB tile is involved. In the example, only the signals from the PWM1 module are modified by the CLB. The signals from PWM2 are carried directly to the device pins for comparison purposes. The input and output waveforms for PWM1 are shown in Figure 4-5 (modes 1 and 2). This image highlights in green the areas where the output is forced high or low by the CLB logic.
Operating Mode | Original PWM A Output | Original PWM B Output | PWM A Output | PWM B Output |
---|---|---|---|---|
Normal | 0 | 0 | 0 | 0 |
0 | 1 | 0 | 1 | |
1 | 0 | 1 | 0 | |
1 | 1 | 1 | 1 | |
Active Low | 0 | 0 | 1 | 1 |
0 | 1 | 0 | 1 | |
1 | 0 | 1 | 0 | |
1 | 1 | 1 | 1 | |
Active High | 0 | 0 | 0 | 0 |
0 | 1 | 0 | 1 | |
1 | 0 | 1 | 0 | |
1 | 1 | 0 | 0 |
The required logic is implemented using 4-input LUTs 0 and 1. Each of these is connected to the two PWM signals, and the two LSBs of the software “mode” variable, which are written to the GPREG register. The CLB outputs are connected to the PWM1A and PWM1B signals which then go to GPIO pins and 1, respectively. Figure 4-6 conceptually shows the connections to and from the CLB tile.
To run the example, follow this procedure:
In the description that follows, it is assumed the C2000Ware directory above is in use.
If running the program on an F28379D LaunchPad board, PWM signals 1A and 1B can be monitored on pins J4/40 and J4/39, respectively. Set up an oscilloscope to monitor the signals at these pins while the program is running.
If running the program on an experimenter’s kit fitted with a F28388D controlCARD, the signals can be found on pins 49 and 51, respectively.
Open a CCS Expressions window and add the program variable “mode”. With mode set to the default value of 0, the PWM signals pass through the CLB without modification. Stop the program and change mode to 1, then restart the program. The signals should be as shown in the timing diagram above. Repeat this procedure to change the mode to 2 and verify the signals are as shown in the previous timing diagram.