SNIU028D February 2016 – September 2020 UCD3138 , UCD3138064 , UCD3138064A , UCD3138128 , UCD3138A , UCD3138A64
The counter is also used by 2 compare blocks. Compare blocks are programmed with a 24 bit value. When the 24 bit counter matches that value, the compare block is triggered.
These compare blocks are best used when the firmware starts an asynchronous process that needs some other event to follow at a fixed interval. Add the desired interval to the current counter value, and put the result into the compare register. When the time elapses, the interrupt will occur, or the TCMP pin will change.
To load the compare register with a fixed interval:
#define FIXED_INTERVAL 100
.....
TimerRegs.T24CMP0DAT.bit.CMP_DAT = TimerRegs.T24CNTDAT.bit.CNT_DAT + FIXED_INTERVAL;
This technique will even work well if an overflow occurs during the interval. Just like the timer, the result will overflow and be clipped.
The configuration of the Compare Blocks is relatively straightforward. Refer to Section 11.22 for details.