Reply by Phil Young April 24, 20122012-04-24
Looking at the code ( I don't have an LPC2xxx to test ), it seems that you
put the timer into PWM mode before setting up PWMMR0 which is used to reset
the timer.

According to the user manual if the timer is in PWM mode you need to set the
bits in PWMLER to transfer values to the PWMMR registers, but when you write
to PWMLER you only write 0x24.

This implies that PWMMR0 would not get updated so the counter may simply be
stuck at zero.

Surely the value written to PWMLER should be 0x25.

Regards

Phil.

From: l... [mailto:l...] On Behalf Of
madbaxyh
Sent: 24 April 2012 22:40
To: l...
Subject: [lpc2000] Re: Help on PWM basic code

I tryed compiling without Startup.s file... uVision didn't show any error
but pwm doesn't work yet.

after that, I used startup.s from another functional project that uses UART,
but pwm doesn't work...

any ideas?



An Engineer's Guide to the LPC2100 Series

Reply by madbaxyh April 24, 20122012-04-24
I tryed compiling without Startup.s file... uVision didn't show any error but pwm doesn't work yet.

after that, I used startup.s from another functional project that uses UART, but pwm doesn't work...

any ideas?

Reply by madbaxyh April 19, 20122012-04-19
I made a doc with some pics:
https://docs.google.com/document/d/1hcYva3DO3pqDP8PF_WoT15I-lBlvV_wW5dHEwy_nmEY/edit

it seems to be DOWN all the time (the voltage is very low)

PS: Sorry about the PWMLER, i didn't know that detail.

--- In l..., "Alexan_e" wrote:
>
> It should work fine , so what is the level you see at the PWM pins?
> Is it constant high or low?
> The pins are not connected to anything and you just connect the osciloscope?
>

Reply by Alexan_e April 19, 20122012-04-19
It should work fine , so what is the level you see at the PWM pins?
Is it constant high or low?
The pins are not connected to anything and you just connect the osciloscope?
----- Original Message -----
From: madbaxyh
To: l...
Sent: Friday, April 20, 2012 2:32 AM
Subject: [lpc2000] Re: Help on PWM basic code

I've made blink and UART tests to the mcu and it worked fine.
I'm trying in two different circuits with the same mcu (LPC2148), both runs the blink and UART codes correctly. also, i do have an oscilloscope for watching the PWM output.

PWM doesn not need special hardware or inputs, does it?

--- In l..., "Alexan_e" wrote:
>
> Apart from the wrong setting for the PWM5 pin everything was already correct.
> Your code works fine in KEIL simulation so there is something wrong with the hardware.
>
> Are you sure that the mcu is programmed properly?
> Have you tried a simple blinky application to see if you can upload and execute some code?
> How fo you check the PWM output , do you have something connected to the pins?
>
> Alex
>



Reply by madbaxyh April 19, 20122012-04-19
I've made blink and UART tests to the mcu and it worked fine.
I'm trying in two different circuits with the same mcu (LPC2148), both runs the blink and UART codes correctly. also, i do have an oscilloscope for watching the PWM output.

PWM doesn not need special hardware or inputs, does it?

--- In l..., "Alexan_e" wrote:
>
> Apart from the wrong setting for the PWM5 pin everything was already correct.
> Your code works fine in KEIL simulation so there is something wrong with the hardware.
>
> Are you sure that the mcu is programmed properly?
> Have you tried a simple blinky application to see if you can upload and execute some code?
> How fo you check the PWM output , do you have something connected to the pins?
>
> Alex
>

Reply by Alexan_e April 19, 20122012-04-19
The PWMLER register is not used in my code because I set all the values of the match registers and then I enable the PWM.
The PWMLER is only needed when the PWM is running and you want to set a new value when a match occur.

Alex

----- Original Message -----
From: madbaxyh
To: l...
Sent: Friday, April 20, 2012 2:18 AM
Subject: [lpc2000] Re: Help on PWM basic code

I gave a try to ARMwizard and it looks so useful but although I
configured PWM module it doesn't work yet.
here is the code generated + PWMLER that didn't apare.



Reply by Alexan_e April 19, 20122012-04-19
Apart from the wrong setting for the PWM5 pin everything was already correct.
Your code works fine in KEIL simulation so there is something wrong with the hardware.

Are you sure that the mcu is programmed properly?
Have you tried a simple blinky application to see if you can upload and execute some code?
How fo you check the PWM output , do you have something connected to the pins?

Alex
----- Original Message -----
From: madbaxyh
To: l...
Sent: Friday, April 20, 2012 2:12 AM
Subject: [lpc2000] Re: Help on PWM basic code

I gave a try to ARMwizard and it looks so useful but although I
configured PWM module it doesn't work yet.
here is the code generated + PWMLER that didn't apare.
/***********************************************************************\
************* Code created using the ARMwizard, visit
http://alexan.edaboard.eu
************************************************************************\
************/
#include

int main(void){/* P0.0: PORT0.0 (General purpose I/O) Input
P0.1: PORT0.1 (General purpose I/O) Input P0.2: PORT0.2 (General
purpose I/open-drain O) Input P0.3: PORT0.3 (General purpose
I/open-drain O) Input P0.4: PORT0.4 (General purpose I/O) Input
P0.5: PORT0.5 (General purpose I/O) Input P0.6: PORT0.6 (General
purpose I/O) Input P0.7: PWM2 (Pulse Width Modulator output 2)
P0.8: PORT0.8 (General purpose I/O) Input P0.9: PORT0.9 (General
purpose I/O) Input P0.10: PORT0.10 (General purpose I/O) Input
P0.11: PORT0.11 (General purpose I/O) Input P0.12: PORT0.12
(General purpose I/O) Input P0.13: PORT0.13 (General purpose I/O)
Input P0.14: PORT0.14 (General purpose I/O) Input P0.15:
PORT0.15 (General purpose I/O) Input P0.16: PORT0.16 (General
purpose I/O) Input P0.17: PORT0.17 (General purpose I/O) Input
P0.18: PORT0.18 (General purpose I/O) Input P0.19: PORT0.19
(General purpose I/O) Input P0.20: PORT0.20 (General purpose I/O)
Input P0.21: PWM5 (Pulse Width Modulator output 5) P0.22:
PORT0.22 (General purpose I/O) Input P0.23: PORT0.23 (General
purpose I/O) Input P0.25: PORT0.25 (General purpose I/O) Input
P0.28: PORT0.28 (General purpose I/O) Input P0.29: PORT0.29
(General purpose I/O) Input P0.30: PORT0.30 (General purpose I/O)
Input P0.31: PORT0.31 (General purpose O) Output P1.16:
PORT1.16 (General purpose I/O) Input P1.17: PORT1.17 (General
purpose I/O) Input P1.18: PORT1.18 (General purpose I/O) Input
P1.19: PORT1.19 (General purpose I/O) Input P1.20: PORT1.20
(General purpose I/O) Input P1.21: PORT1.21 (General purpose I/O)
Input P1.22: PORT1.22 (General purpose I/O) Input P1.23:
PORT1.23 (General purpose I/O) Input P1.24: PORT1.24 (General
purpose I/O) Input P1.25: POR11.25 (General purpose I/O) Input
P1.26: PORT1.26 (General purpose I/O) Input P1.27: PORT1.27
(General purpose I/O) Input P1.28: PORT1.28 (General purpose I/O)
Input P1.29: PORT1.29 (General purpose I/O) Input P1.30:
PORT1.30 (General purpose I/O) Input P1.31: PORT1.31 (General
purpose I/O) Input*/
PINSEL0=0x00008000; /* binary:
00000000_00000000_10000000_00000000 */ IO0DIR=0x80000000; /*
binary: 10000000_00000000_00000000_00000000 */ PINSEL1=0x00000400;
/* binary: 00000000_00000000_00000100_00000000 */ PINSEL2=0x00000000;
/* binary: 00000000_00000000_00000000_00000000 */ IO1DIR=0x00000000;
/* binary: 00000000_00000000_00000000_00000000 */
/***********************************************************************\
*******
PWM*********************************************************************\
********** Counter Enabled, Counter Reset=0, PWM mode enabled
Counter clk: 7.5 MHz, Counts every: 133.33 ns (calculated with
peripheral clock: 60MHz) MCR0.0 : reset, on compare match PWM
frequency: 1 KHz PWM1: Single edge, set by MR0, reset by MR1, output
disabled PWM2: Single edge, set by MR0, reset by MR2, output enabled
PWM3: Single edge, set by MR0, reset by MR3, output disabled PWM4:
Single edge, set by MR0, reset by MR4, output disabled PWM5: Single
edge, set by MR0, reset by MR5, output enabled PWM6: Single edge, set
by MR0, reset by MR6, output disabled*/PCONP = (PCONP & 0x801817BE) |
0x20; /* Enable peripheral clock for PWM0 (default is enabled)
*/PWMTC=0x00000000; /* decimal 0 */PWMPR=0x00000007; /* decimal
7 */PWMMCR=0x00000002; /* binary:
00000000_00000000_00000000_00000010 */PWMMR0=0x00001D4C; /* decimal
7500 */PWMMR1=0x00000000; /* decimal 0 */PWMMR2=0x00000EA6; /*
decimal 3750 */PWMMR3=0x00000000; /* decimal 0 */PWMMR4=0x00000000;
/* decimal 0 */PWMMR5=0x00000EA6; /* decimal 3750
*/PWMMR6=0x00000000; /* decimal 0 */PWMPCR=0x00002400; /*
binary: 00000000_00000000_00100100_00000000 */PWMTCR=0x09; /*
binary: 00001001 */PWMLER=0x24; while(1) { }
}
--- In l..., Alexan_e wrote:
>
> PINSEL1 = 0x300;// Enable PWM5
>
> The above is not correct , the value 0x300 sets P0.20 to EINT3.
> For P0.21 set to PWM5 use PINSEL1=0x00000400;
>
> I would suggest you download ARMwizard to avoid such mistakes
> http://alexan.edaboard.eu/
>
> The power control for PWM can be enabled using:
> PCONP = (PCONP & 0x801817BE) | (1UL<<5); /* Enable peripheral clock
for
> PWM0 (default is enabled) */
>
> Alex
>





Reply by madbaxyh April 19, 20122012-04-19
I gave a try to ARMwizard and it looks so useful but although I
configured PWM module it doesn't work yet.
here is the code generated + PWMLER that didn't apare.

/*********************************************************
Code created using the ARMwizard, visit http://alexan.edaboard.eu
***********************************************************/

#include
int main(void)
{
PINSEL0=0x00008000;/* binary: 00000000_00000000_10000000_00000000 */
IO0DIR=0x80000000;/* binary: 10000000_00000000_00000000_00000000 */
PINSEL1=0x00000400;/* binary: 00000000_00000000_00000100_00000000 */
PINSEL2=0x00000000;/* binary: 00000000_00000000_00000000_00000000 */
IO1DIR=0x00000000;/* binary: 00000000_00000000_00000000_00000000 */

PCONP = (PCONP & 0x801817BE) | 0x20;
PWMTC=0x00000000; /* decimal 0 */
PWMPR=0x00000007; /* decimal 7 */
PWMMCR=0x00000002;
PWMMR0=0x00001D4C; /* decimal 7500 */
PWMMR1=0x00000000; /* decimal 0 */
PWMMR2=0x00000EA6; /* decimal 3750 */
PWMMR3=0x00000000; /* decimal 0 */
PWMMR4=0x00000000; /* decimal 0 */
PWMMR5=0x00000EA6; /* decimal 3750 */
PWMMR6=0x00000000; /* decimal 0 */
PWMPCR=0x00002400;
PWMTCR=0x09; /* binary: 00001001 */
PWMLER=0x24;
while(1)
{

}

}
--- In l..., "Kevin" wrote:
>
> Be careful with using PINSEL1=0x00000400;
> you might accidentally set or reset the functions on other pins as well.
>
> --- In l..., Alexan_e wrote:
> >
> > PINSEL1 = 0x300;// Enable PWM5
> >
> > The above is not correct , the value 0x300 sets P0.20 to EINT3.
> > For P0.21 set to PWM5 use PINSEL1=0x00000400;
> >
> > I would suggest you download ARMwizard to avoid such mistakes
> > http://alexan.edaboard.eu/
> >
> > The power control for PWM can be enabled using:
> > PCONP = (PCONP & 0x801817BE) | (1UL<<5); /* Enable peripheral clock for
> > PWM0 (default is enabled) */
> >
> > Alex
> >
> >
>
Reply by madbaxyh April 19, 20122012-04-19
I gave a try to ARMwizard and it looks so useful but although I
configured PWM module it doesn't work yet.
here is the code generated + PWMLER that didn't apare.
/***********************************************************************\
************* Code created using the ARMwizard, visit
http://alexan.edaboard.eu
************************************************************************\
************/
#include

int main(void){/* P0.0: PORT0.0 (General purpose I/O) Input
P0.1: PORT0.1 (General purpose I/O) Input P0.2: PORT0.2 (General
purpose I/open-drain O) Input P0.3: PORT0.3 (General purpose
I/open-drain O) Input P0.4: PORT0.4 (General purpose I/O) Input
P0.5: PORT0.5 (General purpose I/O) Input P0.6: PORT0.6 (General
purpose I/O) Input P0.7: PWM2 (Pulse Width Modulator output 2)
P0.8: PORT0.8 (General purpose I/O) Input P0.9: PORT0.9 (General
purpose I/O) Input P0.10: PORT0.10 (General purpose I/O) Input
P0.11: PORT0.11 (General purpose I/O) Input P0.12: PORT0.12
(General purpose I/O) Input P0.13: PORT0.13 (General purpose I/O)
Input P0.14: PORT0.14 (General purpose I/O) Input P0.15:
PORT0.15 (General purpose I/O) Input P0.16: PORT0.16 (General
purpose I/O) Input P0.17: PORT0.17 (General purpose I/O) Input
P0.18: PORT0.18 (General purpose I/O) Input P0.19: PORT0.19
(General purpose I/O) Input P0.20: PORT0.20 (General purpose I/O)
Input P0.21: PWM5 (Pulse Width Modulator output 5) P0.22:
PORT0.22 (General purpose I/O) Input P0.23: PORT0.23 (General
purpose I/O) Input P0.25: PORT0.25 (General purpose I/O) Input
P0.28: PORT0.28 (General purpose I/O) Input P0.29: PORT0.29
(General purpose I/O) Input P0.30: PORT0.30 (General purpose I/O)
Input P0.31: PORT0.31 (General purpose O) Output P1.16:
PORT1.16 (General purpose I/O) Input P1.17: PORT1.17 (General
purpose I/O) Input P1.18: PORT1.18 (General purpose I/O) Input
P1.19: PORT1.19 (General purpose I/O) Input P1.20: PORT1.20
(General purpose I/O) Input P1.21: PORT1.21 (General purpose I/O)
Input P1.22: PORT1.22 (General purpose I/O) Input P1.23:
PORT1.23 (General purpose I/O) Input P1.24: PORT1.24 (General
purpose I/O) Input P1.25: POR11.25 (General purpose I/O) Input
P1.26: PORT1.26 (General purpose I/O) Input P1.27: PORT1.27
(General purpose I/O) Input P1.28: PORT1.28 (General purpose I/O)
Input P1.29: PORT1.29 (General purpose I/O) Input P1.30:
PORT1.30 (General purpose I/O) Input P1.31: PORT1.31 (General
purpose I/O) Input*/
PINSEL0=0x00008000; /* binary:
00000000_00000000_10000000_00000000 */ IO0DIR=0x80000000; /*
binary: 10000000_00000000_00000000_00000000 */ PINSEL1=0x00000400;
/* binary: 00000000_00000000_00000100_00000000 */ PINSEL2=0x00000000;
/* binary: 00000000_00000000_00000000_00000000 */ IO1DIR=0x00000000;
/* binary: 00000000_00000000_00000000_00000000 */
/***********************************************************************\
*******
PWM*********************************************************************\
********** Counter Enabled, Counter Reset=0, PWM mode enabled
Counter clk: 7.5 MHz, Counts every: 133.33 ns (calculated with
peripheral clock: 60MHz) MCR0.0 : reset, on compare match PWM
frequency: 1 KHz PWM1: Single edge, set by MR0, reset by MR1, output
disabled PWM2: Single edge, set by MR0, reset by MR2, output enabled
PWM3: Single edge, set by MR0, reset by MR3, output disabled PWM4:
Single edge, set by MR0, reset by MR4, output disabled PWM5: Single
edge, set by MR0, reset by MR5, output enabled PWM6: Single edge, set
by MR0, reset by MR6, output disabled*/PCONP = (PCONP & 0x801817BE) |
0x20; /* Enable peripheral clock for PWM0 (default is enabled)
*/PWMTC=0x00000000; /* decimal 0 */PWMPR=0x00000007; /* decimal
7 */PWMMCR=0x00000002; /* binary:
00000000_00000000_00000000_00000010 */PWMMR0=0x00001D4C; /* decimal
7500 */PWMMR1=0x00000000; /* decimal 0 */PWMMR2=0x00000EA6; /*
decimal 3750 */PWMMR3=0x00000000; /* decimal 0 */PWMMR4=0x00000000;
/* decimal 0 */PWMMR5=0x00000EA6; /* decimal 3750
*/PWMMR6=0x00000000; /* decimal 0 */PWMPCR=0x00002400; /*
binary: 00000000_00000000_00100100_00000000 */PWMTCR=0x09; /*
binary: 00001001 */PWMLER=0x24; while(1) { }
}
--- In l..., Alexan_e wrote:
>
> PINSEL1 = 0x300;// Enable PWM5
>
> The above is not correct , the value 0x300 sets P0.20 to EINT3.
> For P0.21 set to PWM5 use PINSEL1=0x00000400;
>
> I would suggest you download ARMwizard to avoid such mistakes
> http://alexan.edaboard.eu/
>
> The power control for PWM can be enabled using:
> PCONP = (PCONP & 0x801817BE) | (1UL<<5); /* Enable peripheral clock
for
> PWM0 (default is enabled) */
>
> Alex
>



Reply by rtstofer April 19, 20122012-04-19
--- In l..., "Kevin" wrote:
>
> Be careful with using PINSEL1=0x00000400;
> you might accidentally set or reset the functions on other pins as well.
In other words, always use something like:
PINSEL1 |= 0x00000400;

Check out the demo code at www.jcwren.com/arm Everything you could possibly want to know about the LPC2148 is contained in that demo code.

There is a simple example of PWM on the PWM5 output.

I didn't look at the startup code but it will very likely set the peripheral clock. This clock will be the source for the PWM module so understanding the setup is important. The clock setup may be done somewhere other than in the startup file so make sure you track it down.

Richard