lpc1313 / lpcopen pwm

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

lpc1313 / lpcopen pwm

964 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TM1990 on Sun May 11 11:13:31 MST 2014
Hello,

I am trying to get a 20 kHz PWM Signal with lpcopen working.
But I am stuck at one general point.

I would do it like this:

Chip_TIMER_Init(LPC_TIMER16_0);
Chip_TIMER_ExtMatchControlSet(LPC_TIMER16_0, 0,TIMER_EXTMATCH_SET,0);
Chip_TIMER_Enable(LPC_TIMER16_0);

Chip_TIMER_SetMatch(LPC_TIMER16_0, 0, 32768); // 50/50 PWM

Then I should get a PWM but it will run with 72 MHz and will overrun at 65536. So i will only get a frequency about 1 kHz
How can I set an upper limit without the match value to reduce the time for an overrun?
Labels (1)
0 Kudos
6 Replies

819 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by LabRat on Fri Jun 13 10:22:11 MST 2014
:quest:


Quote: TM1990
... 72 MHz...



Just guess why a prescaler of 72 in a 72MHz main clock system is generating this base time...
0 Kudos

819 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by hetii on Fri Jun 13 10:10:19 MST 2014
Hi R2D2.

How you calculate the prescale value and know that it should be 72 for 1us ?
0 Kudos

819 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TM1990 on Mon May 12 05:35:22 MST 2014
[s]
Ok but I think we have a little misunderstanding here. My problem is how do I generate a 20 kHz PWM with a 16 bit Timer and a main frequency of 72 MHz...
I am stuck there.[/s]..

Ok I understand it now sorry... I did not read the last post carefully.
0 Kudos

819 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon May 12 03:39:12 MST 2014
After adding PWMC register in LPCOpen 

http://www.lpcware.com/content/forum/missing-pwmc-register-lpc13xx-lpcopen-v205

and using PR (prescaler) to get 1µs, this sample is generating a simple  10ms PWM (3ms low)
//enable CT16B0_MAT1
 Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO0_9, (IOCON_FUNC2 | IOCON_MODE_PULLUP));
//enable timer 0
 Chip_TIMER_Init(LPC_TIMER16_0);
///MR3 reset
 Chip_TIMER_ResetOnMatchEnable(LPC_TIMER16_0, 3);
//prescaler:72 = time base 1µs
 Chip_TIMER_PrescaleSet(LPC_TIMER16_0, 72-1);
//set match register
 Chip_TIMER_SetMatch(LPC_TIMER16_0, 3, 10000);//length in µs
 Chip_TIMER_SetMatch(LPC_TIMER16_0, 1, 3000);//low in µs
 Chip_TIMER_PWMWrite(LPC_TIMER16_0,(1<<1));//enable PWM MAT1
 Chip_TIMER_Enable(LPC_TIMER16_0); //and run...
0 Kudos

819 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TM1990 on Mon May 12 03:23:37 MST 2014

Quote: R2D2

Quote: TM1990
How can I set an upper limit without the match value to reduce the time for an overrun?



What?

I would suggest to use PWM to generate a PWM signal.

Unfortunately LPCOpen V2.05 does not support PWM  :(



Yes of course I want to use the match registers and the PIO functions to react to the match for my PWM.
But how can I get a higher frequency? I miss something here but I do not know what...

Ok and I think when I add a set for the PWM Register in lpcopen I can get it to do a PWM at the match ouptuts
0 Kudos

819 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Sun May 11 13:58:17 MST 2014

Quote: TM1990
How can I set an upper limit without the match value to reduce the time for an overrun?



What?

I would suggest to use PWM to generate a PWM signal.

Unfortunately LPCOpen V2.05 does not support PWM  :(
0 Kudos