Oct 29, 2020
06:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oct 29, 2020
06:13 AM
Hi,
I recently implemented PWMhl module on my device (Tc222L) . Pwm init without any failures, but it does not works at all. It means it works, but completely different as I configure it.
First issue is that, setting 1000Hz base timer frequency results Is 100Hz output pwm signal ( for clock divider 16 -IfxGtm_Tom_Ch_ClkSrc_cmuFxc0) .
Or frequency is changing between 700 – 1300Hz(for clock divider 1 -IfxGtm_Tom_Ch_ClkSrc_cmuFxclk0 )
Moreover PWM level cannot be changed. Setting pwm value do not change anything, pwm always stays on 10% duty.
What can pe possible fixes ?
my code:
I recently implemented PWMhl module on my device (Tc222L) . Pwm init without any failures, but it does not works at all. It means it works, but completely different as I configure it.
First issue is that, setting 1000Hz base timer frequency results Is 100Hz output pwm signal ( for clock divider 16 -IfxGtm_Tom_Ch_ClkSrc_cmuFxc0) .
Or frequency is changing between 700 – 1300Hz(for clock divider 1 -IfxGtm_Tom_Ch_ClkSrc_cmuFxclk0 )
Moreover PWM level cannot be changed. Setting pwm value do not change anything, pwm always stays on 10% duty.
What can pe possible fixes ?
my code:
#include "Gtm/Tom/PwmHl/IfxGtm_Tom_PwmHl.h"
static IfxGtm_Tom_PwmHl pwm_1;
static IfxGtm_Tom_Timer pwm_tom_1_timer;
static void init_pwm(void){
IfxGtm_Tom_Timer_Config timer_config;
IfxGtm_Tom_PwmHl_Config pwm_config;
IfxGtm_Tom_Timer_initConfig(&timer_config, &MODULE_GTM);
timer_config.base.frequency = 1000;
timer_config.base.minResolution = (1.0 / timer_config.base.frequency) / 1000;
timer_config.tom = IfxGtm_Tom_1;
timer_config.timerChannel = IfxGtm_Tom_Ch_6;
timer_config.clock = IfxGtm_Tom_Ch_ClkSrc_cmuFxc0;
timer_config.triggerOut = &IfxGtm_TOM1_6_TOUT5_P02_5_OUT;
timer_config.base.trigger.outputEnabled = TRUE;
timer_config.base.trigger.enabled = TRUE;
timer_config.base.trigger.triggerPoint = 500;
timer_config.base.trigger.risingEdgeAtPeriod = TRUE;
IfxGtm_Tom_Timer_init(&pwm_tom_1_timer, &timer_config);
IfxGtm_Tom_PwmHl_initConfig(&pwm_config);
IfxGtm_Tom_ToutMapP ccx[1] = {&IfxGtm_TOM1_6_TOUT5_P02_5_OUT};
IfxGtm_Tom_ToutMapP coutx[1] = {&IfxGtm_TOM1_6_TOUT5_P02_5_OUT};
pwm_config.timer = &pwm_tom_1_timer;
pwm_config.tom = IfxGtm_Tom_1;
pwm_config.base.deadtime = 2e-6;
pwm_config.base.minPulse = 1e-6;
pwm_config.base.channelCount = 1;
pwm_config.base.emergencyEnabled = FALSE;
pwm_config.base.outputMode = IfxPort_OutputMode_pushPull;
pwm_config.base.outputDriver = IfxPort_PadDriver_cmosAutomotiveSpeed4;
pwm_config.base.ccxActiveState = Ifx_ActiveState_low;
pwm_config.base.coutxActiveState = Ifx_ActiveState_low;
pwm_config.ccx = ccx;
pwm_config.coutx = coutx;
//pins were initialized earlier
pwm_config.initPins = FALSE;
IfxGtm_Tom_PwmHl_init(&pwm_1, &pwm_config);
}
void set_pwm( uint8 pwm_percent_value){
IfxGtm_Tom_PwmHl *pwm_hi = &pwm_1;
IfxGtm_Tom_Timer *timer = &pwm_tom_1_timer;
Ifx_TimerValue period = IfxGtm_Tom_Timer_getPeriod(timer);
Ifx_TimerValue pwm_value = (uint32)((float32)period *((float32)pwm_percent_value)/ 100.0);
IfxGtm_Tom_Timer_disableUpdate(timer);
IfxGtm_Tom_PwmHl_setOnTime(pwm_hi, &pwm_value);
IfxGtm_Tom_Timer_applyUpdate(timer);
}
- Tags:
- IFX
2 Replies
Jul 14, 2021
08:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jul 14, 2021
08:47 AM
Did you manage to get it working?
Mar 17, 2022
06:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 17, 2022
06:36 AM
Hi, did you working now?
This widget could not be displayed.