LPC55S69 ctimer PWM

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

LPC55S69 ctimer PWM

953 Views
wangyibin
Contributor II

在CTIMER_GetPwmPeriodValue(2, 20, timerClock),把占空比恒定为20%,频率依次调为100HZ 10HZ 5HZ 2HZ时都能在示波器上检测到
相关波形,并且占空比正确。在频率降为1HZ的时候,相关波形不正确,示波器上显示占空比为60%。
请问在lpc55s69中定时器2不支持产生1hz频率的pwm波形吗?

0 Kudos
Reply
3 Replies

944 Views
wangyibin
Contributor II

预分频值为7,g_pwmPeriod=47999999 g_pulsePeriod=4800000
把预分频值改为100后能够成功的在示波器上检测到波形,g_pwmPeriod=95999999,g_pulsePeriod=500654
在CTIMER_GetPwmPeriodValue(1, 30, timerClock);中的第二参数是那个占空比,我设置为30,但用示波器检测到的为25%

0 Kudos
Reply

940 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I have to say when you call the follwoing code

CTIMER_GetPwmPeriodValue(20000, 20, timerClock);
CTIMER_SetupPwmPeriod(CTIMER, CTIMER_MAT_OUT, g_pwmPeriod, g_pulsePeriod, false);
//Can not use kCTIMER_Match_3, which is used to control PWM period

CTIMER_GetPwmPeriodValue(20000, 40, timerClock);
CTIMER_SetupPwmPeriod(CTIMER, kCTIMER_Match_0, g_pwmPeriod, g_pulsePeriod, false);

 

when you configure multiple PWM channel and use the status_t CTIMER_GetPwmPeriodValue(uint32_t pwmFreqHz, uint8_t dutyCyclePercent, uint32_t timerClock_Hz) to compute the variables g_pwmPeriod/g_pulsePeriod, the first parameter pwmFreqHz must be the same for multiple calling CTIMER_GetPwmPeriodValue(), only the duty cycle can be different. Otherwise, there is error.

Hope it can help you

BR

XiangJun Rong

 

 

0 Kudos
Reply

947 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

How about using the code

CTIMER_GetDefaultConfig(ctimer_config_t *config)

config->prescale=100;

BTW, can you tell us the value of the two variables if you set up 1HZ PWM

volatile uint32_t g_pwmPeriod = 0U;
volatile uint32_t g_pulsePeriod = 0U;

 

Hope it can help you

BR

XiangJun Rong

 

 

0 Kudos
Reply