background image

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.

Содержание GPT12 Timer Concatenation 1

Страница 1: ...AURIX TC2xx Microcontroller Training V1 0 0 GPT12_PWM_Generation_1 for KIT_AURIX_TC297_TFT Generation of PWM via GPT12 Please read the Important Notice and Warnings at the end of this document...

Страница 2: ...ts count direction configured to down counting On underflow of timer T3 the Output Toggle Latch T3OTL is toggled and the value of timer T2 or T4 is transferred into timer T3 depending on T3OTL value T...

Страница 3: ...ure which incorporates several 16 bit timers Block GPT1 contains three timers the core timer T3 and two auxiliary timers T2 and T4 All three timers of block GPT1 can run in one of four modes Timer Mod...

Страница 4: ...rdware setup This code example has been developed for the board KIT_AURIX_TC297_TFT_BC Step LED D107 1 is used for this example 1 4 2020 06 05 Copyright Infineon Technologies AG 2020 All rights reserv...

Страница 5: ...BPS1 of the divider Configure the frequency for the timer T3 by setting the prescaler value T3I of the divider Configure the timer T3 mode direction and starting value Configure the two auxiliary tim...

Страница 6: ...mer T3 by using the iLLD function IfxGpt12_T3_setMode Set the counting direction of the timer T3 by calling the iLLD function IfxGpt12_T3_setTimerDirection Set the prescaler of timer T3 by calling the...

Страница 7: ...ng 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 p...

Страница 8: ...g the iLLD functions IfxGpt12_T2_setReloadInputMode and IfxGpt12_T4_setReloadInputMode Set timer T2 value with the iLLD function IfxGpt12_T2_setTimerValue and dutyDownTime as parameter Set timer T4 va...

Страница 9: ...h a pointer to the address of the timer T3 service request the interrupt provider and the interrupt priority number as parameters Enable GPT12 interrupt with the iLLD function IfxSrc_enable and the po...

Страница 10: ...R The ISR implemented in this example calls the iLLD function IfxPort_togglePin to toggle the LED s state The interrupt is triggered every time the timer T3 generates an underflow On underflow of time...

Страница 11: ...n and Test After code compilation and flashing the device observe the LED D107 1 which should be blinking 2 times in a second 1 11 2020 06 05 Copyright Infineon Technologies AG 2020 All rights reserve...

Страница 12: ...www infineon com aurix expert training AURIX Development Studio is available online https www infineon com aurixdevelopmentstudio Use the Import function to get access to more code examples For questi...

Страница 13: ...uct for the intended application and the completeness of the product information given in this document with respect to such application For further information on the product technology delivery term...

Отзывы: