Modify PWM range, from 0 to 100 to 0 to 255

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

Modify PWM range, from 0 to 100 to 0 to 255

1,675 Views
RodrigoEngComp
Contributor I

I wanted to know if I can modify the pulse_period interval just by modifying the parameter variable map.

 

pulse.png

In the PWM update function, as shown in the figure, there is a map of variables tending to 100%, can I change it to this value of 255 and only with that change the PWM resolution?

 

And if not this way, how could I change the PWM resolution of this controller?

 

 

Regards,

 

Labels (1)
0 Kudos
Reply
3 Replies

1,648 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

The PWM resolution is ONLY dependent on the PWM module driving clock frequency, you do not say the LPC part number you are using, I give an example based on LPC5516.

This is CTimer driving clock source, if you select main_clk which is 150MHz at most fro lpc5516, the ctimer PWM signal will have the best the resolution, you can see the PWM as a divider.

 

xiangjun_rong_0-1699843804705.png

If you do not use LPC5516, pls check the SYSCON chapter in the UM.

Hope it can help you

BR

XiangJun Rong

0 Kudos
Reply

1,640 Views
RodrigoEngComp
Contributor I

I am using an LPC54S018, allowing a PWM from 0 to 100% of the duty cycle. But I wanted to increase this resolution and expand this duty cycle value between 0 and 255, 

 

Could you enlighten me for this part number?

 

Regards,

0 Kudos
Reply

1,594 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I come to know your question.

First of all, the code you modified is correct I suppose.

But the actual PWM resolution is dependent on the PWM module driving clock frequency as well as the PWM signal frequency.

For example,for LPC54018, the PWM module driving clock is 180MHz, if your required PWM signal frequency is 180Hz, the PWM period register is 180MHz/180Hz=1000_000, of course, you can get 255 step resolution, the one step is 1000_0000/255=3921.

But if your required PWM signal frequency is 1MHz, the PWM period register is 180MHz/1MHz=18, of course, the duty cycle can be from only 0 to 17, you can not get 255 step resolution.

Hope it can help you

BR

XiangJun Rong