ATOM PWM Problem

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User21781
Level 1
Level 1
Hey, I'm using the TC264 microcontroller to generate some PWM wave to drive a motor, but it just simply behaves wired. So I decided to checkout the waveform using a logic analyzer.

When the duty cycle was set to a value that does not represent a multiple of 50us, TC264 generates a PWM first, and non-active state later as the image shows. (The wave is active low, and should be 1kHz.)

5142.attach

Take the abnormal PWM closer, I found the minimum high period is 50us, and it's 1kHz frequency.

5143.attach

But duty cycle of 50us, 100us, 150us... is normal.

From Infineon AURIX™ TC2xx Microcontroller Training pdf ("https://www.infineon.com/dgdl/Infineon-AURIX_Generic_Timer_Module-TR-v01_00-EN.pdf"), it says "PWM generation with multiple channels
with 16 or 24-bit resolution with as low as 10 ns granularity", so I'm expecting the resolution of ATOM PWM should not be just 50us.

Here is my code, modified from iLLD example. Is anything wrong?

#define ATOM_PWM_CLK 100000000

// ...

if(gtm_inited == 0)
{
IfxGtm_enable(&MODULE_GTM);
IfxGtm_Cmu_setClkFrequency(&MODULE_GTM, IfxGtm_Cmu_Clk_0, ATOM_PWM_CLK);
IfxGtm_Cmu_enableClocks(&MODULE_GTM, IFXGTM_CMU_CLKEN_CLK0);

gtm_inited = 1;
}

IfxGtm_Atom_Pwm_initConfig(&g_atomConfig, &MODULE_GTM);

g_atomConfig.atom = pin.atom;
g_atomConfig.atomChannel = pin.channel;
g_atomConfig.pin.outputPin = &pin;
g_atomConfig.period = period;
g_atomConfig.dutyCycle = dutyCycle;
g_atomConfig.synchronousUpdateEnabled = TRUE;
g_atomConfig.signalLevel = Ifx_ActiveState_low;

IfxGtm_Atom_Pwm_init(&g_AtomDriverPWM_n, &g_atomConfig);
IfxGtm_Atom_Pwm_start(&g_AtomDriverPWM_n, TRUE);

// ...
0 Likes
0 Replies