Announcements

Help us improve the Power & Sensing Selection Guide. Share feedback

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

cross mob
User14675
Level 1
Level 1
Hello all,

I'm trying to use the TOM for output generation of PWM.
The PWM works, but I'm having issues with the FXCLK selection. FXCLK[0 ... 5] is the clock source for TOM and should offer different frequencies (/1, /8, /256, /4096, /65536) should offer different frequencies,
but no matter which one I choose, the output frequency is always the same (as if I chose /1 clock).

I'm using ILLD 1.0.1.0.0.

Configuration of GTM, CMU and TOM is below:


Ifx_GTM *gtm = &MODULE_GTM;

// enable GTM
IfxGtm_enable(gtm);

// GTM global clocks init
IfxGtm_Cmu_setGclkFrequency(gtm, (float)GTM_CFG_GCLK_FREQUENCY);

// configure cmu_clk1 as clock source for FXCLK
IfxGtm_Cmu_setClkFrequency(gtm, IfxGtm_Cmu_Clk_1, 10000000);

// enable cmu_clk1
IfxGtm_Cmu_enableClocks(gtm, IFXGTM_CMU_CLKEN_CLK1);

// select clock source for FXCLKx (ILLD doesn't support this)
gtm->CMU.FXCLK.CTRL.B.FXCLK_SEL = 2; // selects cmu_clk1 as FXCLK source

// enable FXCLK clocks
IfxGtm_Cmu_enableClocks(gtm, IFXGTM_CMU_CLKEN_FXCLK);

...

// tom config struct
IfxGtm_Tom_Pwm_Config TomConfig;

// init config to default values
IfxGtm_Tom_Pwm_initConfig(&TomConfig, gtm);

// set source clock
TomConfig.clock = IfxGtm_Tom_Ch_ClkSrc_cmuFxclk2; // should be cmu_clk1 / 256, but is actually cmu_clk1 ??

// init config values
TomConfig.tom = _tomOutChannel->tom;
TomConfig.tomChannel = _tomOutChannel->channel;
TomConfig.pin.outputPin = _tomOutChannel;
TomConfig.pin.outputMode = PWM_LSDRV_MODE;
TomConfig.pin.padDriver = PWM_LSDRV_PAD_DRIVER;
TomConfig.dutyCycle = 50;
TomConfig.period = 100;

// init TOM
IfxGtm_Tom_Pwm_init(&_tomDriver, &TomConfig);

...



I have checked the register, which shows the clock selection for TOM, and the value is correct (2 = IfxGtm_Tom_Ch_ClkSrc_cmuFxclk2, should be CmuClk1/256).
The PWM output frequency is as if the clock selection was just CmuClk1/1 aka 256 times too fast.

Has anyone managed to run the TOM with divided FXCLK as the clock source?
Has anyone had similar problems?

Thank you!
0 Likes
2 Replies
User19059
Level 1
Level 1
First reply posted First question asked
It is workable as follows, where revising "g_tomConfig.clock = IfxGtm_Tom_Ch_ClkSrc_cmuFxclk1 "can change the longer period of PWM

IfxGtm_Tom_Pwm_Config g_tomConfig; /* Timer configuration structure */
IfxGtm_Tom_Pwm_Driver g_tomDriver; /* Timer Driver structure */

void initGtmTomPwm(void)
{
IfxGtm_enable(&MODULE_GTM); /* Enable GTM */

IfxGtm_Cmu_enableClocks(&MODULE_GTM, IFXGTM_CMU_CLKEN_FXCLK); /* Enable the FXU(Fixed Clock Generation) clock */

/* Initialize the configuration structure with default parameters */
IfxGtm_Tom_Pwm_initConfig(&g_tomConfig, &MODULE_GTM);
//Update default setting as tom from IfxGtm_Tom_0 to IfxGtm_TOM2_5_TOUT91_P13_0_OUT
g_tomConfig.tom = SERVO_7.tom; /* Select the TOM depending on the SERVO_7 */
g_tomConfig.tomChannel = SERVO_7.channel; /* Select the channel depending on the SERVO_7 */
g_tomConfig.clock = IfxGtm_Tom_Ch_ClkSrc_cmuFxclk1; /* brief div 16 */
g_tomConfig.period = PWM_PERIOD; /* Set the timer period */
g_tomConfig.pin.outputPin = &SERVO_7; /* Set the LEDSERVO_7 port pin as output */
g_tomConfig.synchronousUpdateEnabled = TRUE; /* Enable synchronous update */

IfxGtm_Tom_Pwm_init(&g_tomDriver, &g_tomConfig); /* Initialize the GTM TOM */
IfxGtm_Tom_Pwm_start(&g_tomDriver, TRUE); /* Start the PWM */
}
0 Likes
Intl0310
Level 1
Level 1
5 sign-ins First comment on blog First reply posted

Hello, have you solved this problem?

0 Likes