SPRUIR8B april 2020 – july 2023
This example uses CLB1 to generate a rectangular wave and CLB2 to check the rectangular wave generated by CLB1 doesn’t exceed the defined duty cycle and period limits.
CLB1: This example uses the counter and FSM sub-modules of the CLB to implement a rectangular pulse generator. The counter0 generates events on Match1 and Match2 values programmed by the user. While Match2 value defines the period of the waveform generated, (Match2 – Match1) value would determine the ON time. State machine uses these events from the counter to generate the waveform – set the output on Match1 and clear the output on Match2 event. Hence the state bit S0 reflects the output waveform generated. This output is in turn brought out on CLB1 output 4 in order to pass this output to CLB2 via CLB X-Bar. In0 is used as an enable from software for the waveform generation. This too is passed to CLB2 via CLB1 Output 5.
CLB2: This example uses the LUTs, counter, FSM, HLC sub-modules of the CLB to implement a checker on the output generated by CLB1. Following is the signal connectivity to CLB2.
CLB1 Output 4 → CLB X-Bar AUXSIG0 → CLB2 in1 (via Global Mux)
CLB1 Output 5 → CLB X-Bar AUXSIG1 → CLB2 in2 (via Global Mux)
The counter0 counts during the ON time of the received signal on In1. Counter0 Match1 value is set to the limit value on the duty cycle. If match1 event occurs it means that the ON time has exceeded the desired value.
The counter1 resets and starts counting on the rising edge of the received signal on In1. Counter1 Match1 value is set to the limit value on the period. If match1 event occurs it means that the Period has exceeded the desired value.
State machine (FSM1 S0) is used to detect the rising edge of the received signal on In1 and in turn used as reset to counter 1.
Whenever either of the counter match1 events described above occur there will be an interrupt generated to CPU using HLC – as an indicator of the error.
Figure 4-11 gives an outline of how the tiles operate. The match1 event generates a CPU interrupt and the objective is to trigger a CLB interrupt upon error condition detected inside CLB2.
The lower half shows the CLB counter, which commences counting at the start ON time. In the first figure, the duty cycle check and depicted and period check is depicted in the second. If the Match 1 value is reached, an interrupt is generated in either case. 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 the SysCfg file (clb_ex6_siggen.syscfg) in the CCS window and inspect the match 1/2 settings in counter 0 of the CLB1 module. Change these values to update the duty and period of the generated output.
Inspect the match 1 settings of counter 0/1 in the CLB2 module. Change these values to update the duty and period values being checked on the generated output.
Run the program with the default values and verify that the CLB interrupts to not trigger. Then, change the values to result in an error (ex: change CLB2 Counter1 Match1 to 400). Rebuild and run the program to see the code stop inside the CLB2 interrupt service routine.