Implementation
Calculation example of the PWM frequency
Example for 2 Hz PWM signal with 50% duty cycle:
›
Period time of 2 Hz signal is 0.5 s
›
High level time is 0.25 s (period * duty cycle)
›
Within 0.5 s, the timer T12 is incremented 390625 times (0.5 s / 1.28 µs) and has 5 overflows
›
Within 0.25 s, the timer T12 is incremented 195312 times (0.25 s / 1.28 µs) and has 2 overflows
›
Parameters available inside the ISR:
–
Counter value of timer T12 one period ago: 1000
–
Current counter value of timer T12: 63955
–
Counter value when the falling edge occured: 65244
–
Amount of overflows during one PWM period: 5
–
Amount of overflows during PWM high level time: 2
›
Calculation of total amount of increments:
–
Increments before the first overflow: 65534 – 1000 = 64534
–
Increments during the second and the last overflow: (5 - 1) * 65534 = 262136
–
Increments after the last overflow: 63955
–
Total amount of increments: 64534 + 262136 + 63955 = 390625
›
Calculation of increments during high level time:
–
Increments before the first overflow: 65534 – 1000 = 64534
–
Increments during the second and the last overflow: (2 - 1) * 65534 = 65534
–
Increments after the last overflow: 65244
–
Total amount of increments: 64534 + 65534 + 65244 = 195312
›
Calculation of the PWM frequency by dividing the frequency of timer T12 by the total amount of
increments during one PWM period:
–
781250 Hz / 390625 = 2 Hz
›
Duty cycle (increments during high level time / increments during total period) = 195312 / 390625 = 50%
2020-01-17
Copyright © Infineon Technologies AG 2020. All rights reserved.
11
Need help?
Do you have a question about the CCU6 PWM Capture 1 and is the answer not in the manual?
Questions and answers