Implementation
Reload Values calculation example
Calculating the correct reload value to generate a PWM signal, depending on the given
frequency f and duty cycle, is done in the initialization function
initGpt12PWM()
:
›
Get the GPT12 module base frequency
𝑓
𝐺𝑃𝑇
by calling the iLLD function
IfxGpt12_getModuleFrequency()
›
Calculate the timer frequency with the following formula:
The GPT1 block prescaler is set to
IfxGpt12_Gpt1BlockPrescaler_32
,
𝑓
𝐺𝑃𝑇
is divided by
32
The timer prescaler is set to
IfxGpt12_TimerInputPrescaler_32
,
𝑓
𝐺𝑃𝑇
is divided by
32
›
Calculate
dutyUpTime
and
dutyDownTime
with the following formulas:
𝑓
𝑡𝑖𝑚𝑒𝑟
=
𝑓
𝐺𝑃𝑇
GPT1_BLOCK_PRESCALER
×
TimerInputPrescaler
𝒅𝒖𝒕𝒚𝑼𝒑𝑻𝒊𝒎𝒆 =
𝑓
𝑡𝑖𝑚𝑒𝑟
×
𝑑𝑢𝑡𝑦𝐶𝑦𝑐𝑙𝑒
100
𝑓
𝒅𝒖𝒕𝒚𝑫𝒐𝒘𝒏𝑻𝒊𝒎𝒆 =
𝑓
𝑡𝑖𝑚𝑒𝑟
× 1 −
𝑑𝑢𝑡𝑦𝐶𝑦𝑐𝑙𝑒
100
𝑓
7
2020-06-05
Copyright © Infineon Technologies AG 2020. All rights reserved.