SPRUIR8B april 2020 – july 2023
This example uses the counter, FSM, and HLC sub-modules of the CLB to implement an event timing feature which detects whether an interrupt service routine takes too long to respond to an interrupt. The example configures four PWM modules to operate in up-count mode and generate a low-to-high edge on a timer zero match event. The zero match event also triggers a PWM ISR which, for the purposes of this example, contains a dummy payload of variable length. At the end of the ISR, a write operation takes place to a CLB GP register to indicate the ISR has ended.
The PWM timer zero event is detected by a CLB module where it starts a timer. The timer “match 2” count is set as the maximum expected duration of the corresponding PWM ISR. If the GP register write does not take place before the match 2 count is reached, the HLC triggers a CLB interrupt. Four PWM modules and CLB tiles are configured similarly.
Figure 4-10 gives an outline of how one tile operates. The upper half shows the configuration of the PWM module to generate a fixed frequency waveform with rising edge on each counter zero match, and falling edge on compare A match. The zero match event generates a CPU interrupt and the objective is to trigger a CLB interrupt if the PWM ISR does not complete within a specified time.
The lower half shows the CLB counter, which commences counting at the start of the PWM ISR. If the ISR does not respond before the Match 2 value is reached, an interrupt is generated. The CLB ISR contains an “ESTOP” instruction which acts like a software break-point in the program.
To run the example, follow this procedure:
In the description that follows, it is assumed the C2000Ware directory above is in use.
Open a CCS Expressions window and add the four program variables: “payload_x”, where ‘x’ is 1 to 4. Observe that at the start of the program, all payload variables have been set to 45. The payload is implemented as a ‘for’ loop in each PWM ISR, each iteration of which takes 12 cycles, so a payload of 45 corresponds to approximately 540 cycles.
Open the .syscfg file and inspect the match 2 settings in counter 0 of the four CLB modules. Notice that all timer limits are set to 3200.
Run the program with the default payloads and verify that the CLB interrupts to not trigger. Then, stop the program and increase any of the payloads. Re-run the program and determine whether any of the ISR limits is exceeded. Keep in mind that since the PWMs are not synchronized, the worst case ISR latency is the cumulative sum of all the payloads plus interrupt overheads.