SBAS646A November 2018 – August 2020 DRV5057
PRODUCTION DATA
If a capture and compare timer is not available, a standard timer interrupt and a counter can be used. Configure the timer interrupt to be significantly faster than the period of the PWM, based on the desired resolution. Count how many times the timer interrupts while the signal is high (OnTime), then count how many times the timer interrupts while the signal is low (OffTime). Then use Equation 1 to calculate the duty cycle.