SPRUIR8B april 2020 – july 2023
This example configures a CLB tile as an auxiliary PWM generator. The example uses combinatorial logic (LUTs), state machines (FSMs), counters, and the high level controller (HLC) to demonstrate the PWM output generation capabilities using CLB.
The PWM generator operates at the CLBCLK frequency. The FSM is used to set/clear the PWM. The PWM is set on a CMP match event, which is tied to match2 of the COUNTER_0. The PWM is cleared on a Zero match event (Z). This event is tied to the COUNTER_0 match1 output.
The PWM register is configured to use active and shadow registers, which is done using the HLC block. The HLC is used to generate an interrupt on the period match event, match1. When an interrupt occurs, a new counter match value is loaded into the HLC register (R0). The new counter match value is then moved into the match2 register of COUNTER_0. This updates the CMP match value, which in turn updates the value of the positive duty cycle. In this example, the user alternates between two values for the positive duty cycle. Figure 4-1 shows in principle what the PWM generator does. Notice how the duty cycle in the next period is changed.
The CLB tile takes a PWM enable signal as input and generates an interrupt to the CPU. The CLB tile is configured to use a counter to count up until the desired period and compare event values are met. When the counter reaches the compare event match value, at output ‘match2’, the output is driven high and remains high until the counter value for the period match, at output ‘match1’, is met or a counter reset is triggered. When the period event or reset occurs, the counter is reset to 0 and the output is driven low and the counter begins counting up. This output logic is configured using the logical equation entered in the FSM. In this example, the period is 300 CLBCLK cycles (3 µs). The compare event occurs at either 100 CLBCLK cycles (1 µs) or 150 CLBCLK cycles (1.5 µs).
The PWM signal can be viewed by feeding the output of the FSM into OUTLUT_4. In order to view the output on a scope, it has to be transmitted via the Output X-BAR to the GPIO Mux.
To run the example, follow this procedure:
In the description that follows, it is assumed the C2000Ware directory above is in use.
Signal | F28379D LaunchPad | F280049 controlCARD | F28388D controlCARD |
Interrupt | GPIO0 on pins J4/40 | pin 49 (GPIO0) | pin 49 (GPIO0) |
Auxiliary PWM | OutputXBAR1 signal on pins J4/34 | pin 53 (OutputXBAR1) | pin 53 (OutputXBAR1) |