why S32K144 Duty cycle is 0-8000(HEX)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

why S32K144 Duty cycle is 0-8000(HEX)

831 Views
Gargi2021
Contributor I

Hi Team,

i observed that the duty cycle is fixed from 0-8000 in FTM_timer1.

when my system clock is 48MHz and PWM frequency is 1KHz, the period is 48000.

and my maximum duty cycle will be 32768.

my doubt is when i will be taking PWM frequency as 10KHz or above, the period is 4800 which is less than 32768.

in this case also the duty will remain 32768 or we can change duty.

Thanks,

Gargi 

0 Kudos
Reply
3 Replies

823 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

there are two types of duty cycle update

FTM_PWM_UPDATE_IN_DUTY_CYCLE : written value can be between 0 - FTM_MAX_DUTY_CYCLE
(0 = 0% and FTM_MAX_DUTY_CYCLE (0x8000) = 100% ). Driver is recalculating this value based on configured period in ticks. 

FTM_PWM_UPDATE_IN_TICKS : written value can be between 0 and ftmPeriod in ticks, which is stored in the driver state structure.

For more info you can refer to UpdatePwmChannel function code. 

BR, Petr

0 Kudos
Reply

810 Views
Gargi2021
Contributor I

Hi Petr,

Thanks for reply,

i just want to ask if i am not using for loop, and i will set duty cycle from gui 50%  and just want to see updated duty cycle in console window. how can i do that. in this case do i need to use FTM_PWM_UPDATE_IN_DutyCycle update.

means i will use only FTM_DRV_UpdateChannel function not in for loop and see the updated duty cycle.

//For (dutyCycle = 0; dutyCycle < 32768; dutyCycle += 500)
//{
FTM_DRV_UpdatePwmChannel(INST_FLEXTIMER_PWM_1,
flexTimer_pwm_1_IndependentChannelsConfig[0].hwChannelId,
FTM_PWM_UPDATE_IN_TICKS, (uint16_t)dutyCycle,
0U,
true);
delayCycles(1);

//}

 

please suggest.

Thanks,

Gargi

0 Kudos
Reply

801 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

yes after using FTM_DRV_UpdatePwmChannel the duty cycle is updated, also depends on synchronization option selected in setting.

BR, Petr

0 Kudos
Reply