Generating PWM in 1 HZ frequency

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

Generating PWM in 1 HZ frequency

749 Views
AJ369
Contributor I

I referred sdk pwm example and I created a PWM1 using submodule 0 with channel B. My clock is IPG(150 MHZ) prescaled by 128 so clock equal to 1.1MHZ. I want to create 1 hz(1 sec ) PWM.

I got only 128 HZ maximum with my configuration. Kindly help me to solve this issue.

 

Configuration added below:-

 

Peripheral.c

pwm_config_t PWM1_SM0_config = {
.clockSource = kPWM_BusClock,
.prescale = kPWM_Prescale_Divide_128,
.pairOperation = kPWM_Independent,
.initializationControl = kPWM_Initialize_LocalSync,
.reloadLogic = kPWM_ReloadImmediate,
.reloadSelect = kPWM_LocalReload,
.reloadFrequency = kPWM_LoadEveryOportunity,
.forceTrigger = kPWM_Force_Local,
.enableDebugMode = false,
.enableWait = false
};

peripheral.h

 

#define PWM1_SM0_COUNTER_CLK_SOURCE_FREQ_HZ 1171875U
/* Definition of submodule 0 counter (PWM) frequency in Hertz */
#define PWM1_SM0_COUNTER_FREQ_HZ 1000U

 

Setting pwm:-

PWM_SetupPwm(peripheral, subModule, chnlParams, numOfChnls, mode, 1UL,
1171875U);

 

Need some support on this.

 

Thanks!

Labels (1)
Tags (1)
0 Kudos
2 Replies

725 Views
_Leo_
NXP TechSupport
NXP TechSupport

Hi Alan, 

What you can do is reduce the IPG_CLK_ROOT to 200 kHz and using a prescale of 4, with that you can get the frequency of 1 Hz in your PWM.

nxf86756_0-1655323543016.png

 

Tags (1)
0 Kudos

517 Views
AJ369
Contributor I

Hi,

 

Sorry for the late reply. I tried based on your screen shot  but I faced some issue in clock settings.

can you pls help me on this.

When I try to make 600KHz AHB and 200KHZ IPG its showing some error.

AJ369_0-1667818749265.pngAJ369_1-1667818787877.png

 

I need one more details is it possible to configure pwm frequency to 0.5Hz

PWM_SetupPwm(PWM_Type *base,
pwm_submodule_t subModule,
const pwm_signal_param_t *chnlParams,
uint8_t numOfChnls,
pwm_mode_t mode,
uint32_t pwmFreq_Hz,
uint32_t srcClock_Hz);

 

Please support me on this.

 

Thanks!

0 Kudos