6 (max) PWMs on LPC832: working project

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

6 (max) PWMs on LPC832: working project

428 Views
aaronm
Contributor III

As a follow-up to

If you try to use the Peripheral configuration tool, you can get 4 working PWMs, maximum, due to the "Number of events exceeds 8 events supported by peripheral SCT0 (each PWM signal internally allocates 2 events)" error.  The fact that there are 8 maximum events, but 6 potential outputs, and the internal limitations on PWM creation is quite annoying, but it is possible to work around it and get all six (on this chip) SCT outputs active at one time.

The trick was hidden in Alice's document: You have to configure the PWM pulse and the period pulse events separately.  So, six events for the duration of the PWMs, one for each output; and one event for the entire PWM period.  7 events total.  See the image in section 1 of Alice's document.  I've attached an MCUXpresso project that you can study for tips.  See the my_SetupPwm, and my_UpdatePwmDutycycle functions, in particular.  In my testing environment, it seems to work.

Granted, this isn't as simple as other tasks you can accomplish with the Peripherals configuration tool, and it would be greatly appreciated if that tool were updated to support this more naturally.  But this does show you how it can be done.  Happy SCT'ing.

Labels (1)
0 Kudos
Reply
1 Reply

413 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I have checked the data sheet of LPC832, the SCTimer has 8 match/capture registers,has 8 events, can output 6 PWM signals.

For PWM signal with edge-alignment mode, of course, 6 PWM s signal requires 12 events, or at least 13 match register(one match register control period), of course, it is impossible.

But you can generate PWM signals with center-alignment mode, in the mode, each PWM signal requires only one event, accordingly one match register, 6 PWM signal requires 6 events and 6 match register, adding one match register for period, you can generate 6 PWM signals with different duty cycle, the required resources are  6 events and 7 match registers. But all the PWM signals are center-alignment, PWM phase shift feature is impossible to implement in the mode.

Pls check if center-alignment mode meets your application.

The AN11538 has the code for center-alignment mode , pls refer to she section 7 7. Center aligned PWM in the AN.

 

Hope it can help you

BR

XiangJun Rong

 

 

0 Kudos
Reply