lpc 1347 PWM

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

lpc 1347 PWM

1,337 Views
mateuszkiełbasa
Contributor III

I am beginner. I would like to write simple program, which use pwm. I searched in manual but I didn't find any helpful information. Can someone tell in which chapter manual describes pwm? http://www.nxp.com/documents/user_manual/UM10524.pdf  . It will be Systick Handler? Thanks!

Labels (1)
5 Replies

761 Views
sergedemaseneer
Contributor III

I use a LPC1347 to control a RGBW ledstrip. The PWM frequency I use is 10kHz and is working to satisfaction.

0 Kudos

761 Views
Badman
Contributor I

Value set to show an example :smileyhappy:

Look at the picture:

MCR.png

If you want to reset the counter when it reaches the value of the MR0 register, you must set bit 1 in MCR

LPC_TMR16B0->MCR = 1<<1;

If you want to reset the counter when it reaches the value of the MR0 register and generate interrupt, you must set bit 0 and 1

LPC_TMR16B0->MCR = 1<<0 | 1<<1;

What frequency to work with PWM ?

0 Kudos

761 Views
Badman
Contributor I

No, You must use timer CT16B0/1 or CT32B0/1, see 16.7.12 PWM Control register and 17.7.12 PWM Control Register.
The following code, which I have not tested:

#include "LPC13xx.h"

int main(void) {

     /* IO CONFIG */
     LPC_SYSCON->SYSAHBCLKCTRL |= 1<<16;     // enable IOCON

     LPC_IOCON->PIO0_8 |= 0x2; // CT16B0_MAT0

     /* TIMER CONFIG */

     LPC_SYSCON->SYSAHBCLKCTRL |= 1<<7; // enable CT16B0

     LPC_TMR16B0->MR3 = 1000;     // timer period
     LPC_TMR16B0->MR0 = 500;          // 50% duty cycle
     LPC_TMR16B0->MCR |= 1<10;     // reset TC on match MR3
     LPC_TMR16B0->PWMC |= 1<0;     // enable PWM on CT16B0_MAT0


     LPC_TMR16B0->TCR = 1; // start timer and PWM

     while(1) {

    }
    return 0 ;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Mateusz are you from Poland ?

0 Kudos

761 Views
eleuterio
Contributor I

Hi Tom,

Why did you choose a value of 1000 for the timer period?

I need to control an RGB LED through PWM and I'm having a hard time configuring the registers.. I have setup MR0-MR2 to control the three PWM signals I need, but I don't understand how to configure MCR. Any help would be greatly appreciated.

Thank you very much

761 Views
soledad
NXP Employee
NXP Employee

Hi,

Please check the following tutorial and let me know if this helps.

LPC1768: PWM - Tutorials 


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos