Reply by Daniel Widyanto January 28, 20112011-01-28
Hi Todd,
's...@ptmelec.com' is right.
The LER needs to be written after the MRx values are filled, except for the first time initialization when PWM-mode in TCR hasn't been set. Otherwise, new MRx values will not be used by PWM.
Regards,-daniel

--- On Fri, 1/28/11, Todd Gilbert wrote:

From: Todd Gilbert
Subject: RE: [lpc2000] Re: PWM Explanation
To: l...
Date: Friday, January 28, 2011, 4:40 PM

I'm using the LPC2368. The code seems to work.


To: l...
From: s...@ptmelec.com
Date: Fri, 28 Jan 2011 16:28:14 +0000
Subject: [lpc2000] Re: PWM Explanation


Which device are you using?
I'm looking at the 2478 spec and for that your values for
TCR,and LER should be
0x05, and 0x55
also, if I understand right, LER needs to be written to after writing the MRs.

--- In l..., "Todd Gilbert" wrote:
>
> Sorry - realized I forget about including PWM1MRx in the reply. Here's the complete PWM code. The question again: is there anything missing?
>
> PINSEL3 |= (0x02 << 8); /* PWM1.2 */
> PINSEL3 |= (0x02 << 14) /* PWM1.4 */
> PINSEL3 |= (0x02 << 20) /* PWM1.6 */
> PWM1PCR = 0x5454; /* all set up in 1 line of code */
> PWM1MCR = (0x01 << 1); /* set up match control to reset on MR0 */
> PWM1TCR = 0x41; /* enable TCR and PWM */
> PWM1LER = 0x01; /* enable LER and latch values into PWM */
>
> PWM1MR0 = cycle;
> PWM1MR1 = 0;
> PWM1MR2 = cycle*1/3;
> PWM1MR3 = cycle*1/3;
> PWM1MR4 = cycle*2/3;
> PWM1MR5 = cycle*2/3;
> PWM1MR6 = cycle;

An Engineer's Guide to the LPC2100 Series

Reply by Todd Gilbert January 28, 20112011-01-28
I'm using the LPC2368. The code seems to work.

To: l...
From: s...@ptmelec.com
Date: Fri, 28 Jan 2011 16:28:14 +0000
Subject: [lpc2000] Re: PWM Explanation

Which device are you using?
I'm looking at the 2478 spec and for that your values for
TCR,and LER should be
0x05, and 0x55
also, if I understand right, LER needs to be written to after writing the MRs.

--- In l..., "Todd Gilbert" wrote:
>
> Sorry - realized I forget about including PWM1MRx in the reply. Here's the complete PWM code. The question again: is there anything missing?
>
> PINSEL3 |= (0x02 << 8); /* PWM1.2 */
> PINSEL3 |= (0x02 << 14) /* PWM1.4 */
> PINSEL3 |= (0x02 << 20) /* PWM1.6 */
> PWM1PCR = 0x5454; /* all set up in 1 line of code */
> PWM1MCR = (0x01 << 1); /* set up match control to reset on MR0 */
> PWM1TCR = 0x41; /* enable TCR and PWM */
> PWM1LER = 0x01; /* enable LER and latch values into PWM */
>
> PWM1MR0 = cycle;
> PWM1MR1 = 0;
> PWM1MR2 = cycle*1/3;
> PWM1MR3 = cycle*1/3;
> PWM1MR4 = cycle*2/3;
> PWM1MR5 = cycle*2/3;
> PWM1MR6 = cycle;
> --- In l..., "Todd Gilbert" wrote:
> >
> > I'm experimenting with this, to improve my understanding. Here's what I have so far - what am I excluding?.
> >
> > PINSEL3 |= (0x02 << 8); /* PWM1.2 */
> > PINSEL3 |= (0x02 << 14) /* PWM1.4 */
> > PINSEL3 |= (0x02 << 20) /* PWM1.6 */
> > PWM1PCR = 0x5454; /* all set up in 1 line of code */
> > PWM1MCR = (0x01 << 1); /* set up match control to reset on MR0 */
> > PWM1TCR = 0x41; /* enable TCR and PWM */
> > PWM1LER = 0x01; /* enable LER and latch values into PWM */
> >
> >
> > --- In l..., "John S" wrote:
> > >
> > >
> > > Use pins pwm1.2,pwm1.4,pwm1.6
> > >
> > > Use mr0 to reset tc. This sets period.
> > > For your 6 edges:
> > > use mr1 and mr2 to specify edges for pwm1.2
> > > use mr3 and mr4 to specify edges for pwm1.4
> > > use mr5 and mr6 to specify edges for pwm1.6
> > >
> > >
> > > --- In l..., "Todd Gilbert" wrote:
> > > >
> > > > What if I generated the three-phase signal this way?
> > > > 1) Set PWM1MR0
> > > > 2) Turn on PWM1MR1 output
> > > > 3) delay
> > > > 4) Turn off PWM1MR1 output
> > > > 5) Turn on PWM1MR2 output
> > > > 6) delay
> > > > 7) Turn off PWM1MR2 output
> > > > 8) Turn on PWM1MR3 output
> > > > 9) delay
> > > > 10) Turn off PWM1MR3 output
> > > > 11) go to 2
> > > >
> > > > It's not graceful coding, but I think it would work.
> > > >
> > > >
> > > > --- In l..., Todd Gilbert wrote:
> > > > >
> > > > >
> > > > > Thanks Chris,
> > > > >
> > > > > * Understanding how to use the PWM is step one - that is still developing.
> > > > > * Step two is creating an algorithm to make a LCD icon appear to "breathe". I accomplished this by controlling the pulse width. Required a little thought, but works great.
> > > > > * Step three (which I haven't figured out how to do yet) is writing an algorithm/code to output three dependent waveforms. They are 120 degrees apart (i.e. - if period is 300: first is active from period=0-100; next is active from period0 to 200; and third is active from period 0-300). This repeats indefinitely. I am using three LCD icons (in the shape of arrows) around a circle. The idea is to cycle them to show movement. Is this something that can be accomplished using single edge control? Hopefully, since I think I will be utilizing most of the PWMs. Will you point me in the direction of an example, or walk me through the process?
> > > > >
> > > > > Best Regards (and thanks again),
> > > > > Todd
> > > > >
> > > > >
> > > > >
> > > > > To: l...
> > > > > From: daniel.widyanto@
> > > > > Date: Thu, 27 Jan 2011 03:39:05 -0800
> > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Hi,
> > > > >
> > > > >
> > > > > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > > > > PWM1PCR = (0x01 << 11); //enable PWM3 as single-edge, PWM1.3 as output
> > > > > // Read Ch 24 Sec 4 for MR0 and MR3 effect on PWM1.3
> > > > > PWM1MR3 |= 1000; //half frequency..at PWM1 = 1000, PWM1.3 will be low
> > > > > PWM1MR0 |= 2000; //period...at PWM1 = 2000, PWM1.3 will be high
> > > > > PWM1LER |= 0x09; //latch MR0 and MR3 new values into PWM peripheral
> > > > > PWM1MCR = (1 << 1); // Reset PWM counter value when it reach 2000 (MR0 value)
> > > > > PWM1TCR = 0x09; //enable pwm and the shadow register
> > > > >
> > > > >
> > > > > Regards,
> > > > > -daniel
> > > > >
> > > > > --- On Tue, 1/25/11, Todd Gilbert wrote:
> > > > >
> > > > >
> > > > > From: Todd Gilbert
> > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > > To: l...
> > > > > Date: Tuesday, January 25, 2011, 2:30 PM
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > strike 2.
> > > > >
> > > > >
> > > > > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > > > > PWM1PCR |= (0x01 << 11); //enable PWM3 as output
> > > > > PWM1MRO |= 2000; //period
> > > > > PWM1MR1 |= 1000; //half period
> > > > > PWM1TCR |= 0x01; //enable pwm
> > > > > PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure about this?
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > To: l...
> > > > > From: toddgilbert@
> > > > > Date: Tue, 25 Jan 2011 14:07:44 +0000
> > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Let's set up a hypothetical. I want a single-edge triggered waveform on PWM1.3.
> > > > >
> > > > > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > > > > PWM1PCR |= (0x01 << 11); //enable PWM3 as output
> > > > > PWM1MRO |= 2000; //frequency
> > > > > PWM1MR1 |= 1000; //half frequency
> > > > > PWM1TCR |= 0x01; //enable pwm
> > > > > PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure about this?
> > > > >
> > > > > Is this right, and what else needs to be set?
> > > > >
> > > > >
> > > > >
> > > > > To: l...
> > > > > From: toddgilbert@
> > > > > Date: Tue, 25 Jan 2011 13:56:03 +0000
> > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > That's good to know. Thanks.
> > > > >
> > > > >
> > > > >
> > > > > To: l...
> > > > > From: simon.baxter@
> > > > > Date: Tue, 25 Jan 2011 13:52:20 +0000
> > > > > Subject: [lpc2000] Re: PWM Explanation
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Caution : You do need to remember though, that the |= operator reads the existing contents of PINSEL3 and ONLY sets those bits to 1 that ARE NOT already set !!! it won't clear a bit to zero !!! so it can catch you out if your changing the pin function during the code execution, i.e. from PWM1.4 to a GPIO pin.
> > > > >
> > > > > --- In l..., "simonb65" wrote:
> > > > > >
> > > > > > Todd .. Yes!
> > > > > >
> > > > > > You will usually see it the pins set individually as the program configures the separate functional areas of code ...
> > > > > >
> > > > > > PINSEL3 |= (0x2 << 10); // PWM1.3
> > > > > > PINSEL3 |= (0x2 << 14); // PWM1.4
> > > > > > etc
> > > > > >
> > > > > > or sometime you see the whole port setup in a single operation ...
> > > > > >
> > > > > > PINSEL = 0x00008800; // PWM1.3, PWM1.4, etc
> > > > > >
> > > > > > it is dependant upon how people structure the code and how small you want your end code and hardware intialization time.
> > > > > >
> > > > > > Regards,
> > > > > > Simon.
> > > > > > --- In l..., Todd Gilbert wrote:
> > > > > > >
> > > > > > >
> > > > > > > Sorry - meant PINSEL3 |= 0x2 << 10; PINSEL3 |= 0x800; and PINSEL3 |= 2048
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > From: toddgilbert@
> > > > > > > To: l...
> > > > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > > > > Date: Tue, 25 Jan 2011 13:29:53 +0000
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > okay, I think I'm catching on. If I look at PWM1.3...
> > > > > > >
> > > > > > > PINSEL3 |= 0x2 << 10; PINSEL3 |= 0x700; and PINSEL3 |= 1792 are all equivalent?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > To: l...
> > > > > > > From: tim@
> > > > > > > Date: Tue, 25 Jan 2011 12:40:50 +0000
> > > > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > ----Original Message----
> > > > > > > From: l...
> > > > > > > [mailto:l...] On Behalf Of Todd Gilbert
> > > > > > > Sent: 25 January 2011 12:16 To: l...
> > > > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > > > >
> > > > > > > > I apologize if I offended anyone - not my intent -
> > > > > > > > probably my frustration showing. BTW, I have seen the
> > > > > > > > header file and chapter 24. What I'm confused about is
> > > > > > > > how to assign values to those keywords, and when they are
> > > > > > > > necessary to reference (maybe if I see more PWM examples,
> > > > > > > > things will come together). For example, I've seen
> > > > > > > > "PINSEL3 |= (0x2 << 8)" and "PINSEL3 |= 0x20".
> > > > > > > > Meanwhile, PINSEL3 is defined in pairs (e.g. 11:10). How
> > > > > > > > is PINSEL3 |= (0x2 << 8) related to PINSEL3, pins 9:8 -
> > > > > > > > is the MSB (i.e. 9) the pin that defines PWM1.2?. I'm
> > > > > > > > not quite sure how this all works. Thanks for your help.
> > > > > > >
> > > > > > > (0x2)<<8 moves the bit pattern "10" to bit 8
> > > > > > >
> > > > > > > i.e. bit 9 will be set, bit 8 will be clear
> > > > > > >
> > > > > > > (0x03)<<8 would set both bits 9 and 8.
> > > > > > >
> > > > > > > It's written like this to make it easier to understand what the program is doing, you could equally put PINSEL3 |= 0x0100 but then it's harder to see which bits are getting set.
> > > > > > >
> > > > > > > For PINSEL, there are 2 bits for each IO pin which define what is connected to it.
> > > > > > > Normally 00 is the standard IO pin then there are 3 other settings which connect a peripheral to the pin.
> > > > > > >
> > > > > > > in the user manual section on Pin Connect Block, it tells you what these settings are.
> > > > > > >
> > > > > > > --
> > > > > > > Tim Mitchell
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
>
Reply by John S January 28, 20112011-01-28
Which device are you using?
I'm looking at the 2478 spec and for that your values for
TCR,and LER should be
0x05, and 0x55
also, if I understand right, LER needs to be written to after writing the MRs.

--- In l..., "Todd Gilbert" wrote:
>
> Sorry - realized I forget about including PWM1MRx in the reply. Here's the complete PWM code. The question again: is there anything missing?
>
> PINSEL3 |= (0x02 << 8); /* PWM1.2 */
> PINSEL3 |= (0x02 << 14) /* PWM1.4 */
> PINSEL3 |= (0x02 << 20) /* PWM1.6 */
> PWM1PCR = 0x5454; /* all set up in 1 line of code */
> PWM1MCR = (0x01 << 1); /* set up match control to reset on MR0 */
> PWM1TCR = 0x41; /* enable TCR and PWM */
> PWM1LER = 0x01; /* enable LER and latch values into PWM */
>
> PWM1MR0 = cycle;
> PWM1MR1 = 0;
> PWM1MR2 = cycle*1/3;
> PWM1MR3 = cycle*1/3;
> PWM1MR4 = cycle*2/3;
> PWM1MR5 = cycle*2/3;
> PWM1MR6 = cycle;
> --- In l..., "Todd Gilbert" wrote:
> >
> > I'm experimenting with this, to improve my understanding. Here's what I have so far - what am I excluding?.
> >
> > PINSEL3 |= (0x02 << 8); /* PWM1.2 */
> > PINSEL3 |= (0x02 << 14) /* PWM1.4 */
> > PINSEL3 |= (0x02 << 20) /* PWM1.6 */
> > PWM1PCR = 0x5454; /* all set up in 1 line of code */
> > PWM1MCR = (0x01 << 1); /* set up match control to reset on MR0 */
> > PWM1TCR = 0x41; /* enable TCR and PWM */
> > PWM1LER = 0x01; /* enable LER and latch values into PWM */
> >
> >
> > --- In l..., "John S" wrote:
> > >
> > >
> > > Use pins pwm1.2,pwm1.4,pwm1.6
> > >
> > > Use mr0 to reset tc. This sets period.
> > > For your 6 edges:
> > > use mr1 and mr2 to specify edges for pwm1.2
> > > use mr3 and mr4 to specify edges for pwm1.4
> > > use mr5 and mr6 to specify edges for pwm1.6
> > >
> > >
> > > --- In l..., "Todd Gilbert" wrote:
> > > >
> > > > What if I generated the three-phase signal this way?
> > > > 1) Set PWM1MR0
> > > > 2) Turn on PWM1MR1 output
> > > > 3) delay
> > > > 4) Turn off PWM1MR1 output
> > > > 5) Turn on PWM1MR2 output
> > > > 6) delay
> > > > 7) Turn off PWM1MR2 output
> > > > 8) Turn on PWM1MR3 output
> > > > 9) delay
> > > > 10) Turn off PWM1MR3 output
> > > > 11) go to 2
> > > >
> > > > It's not graceful coding, but I think it would work.
> > > >
> > > >
> > > > --- In l..., Todd Gilbert wrote:
> > > > >
> > > > >
> > > > > Thanks Chris,
> > > > >
> > > > > * Understanding how to use the PWM is step one - that is still developing.
> > > > > * Step two is creating an algorithm to make a LCD icon appear to "breathe". I accomplished this by controlling the pulse width. Required a little thought, but works great.
> > > > > * Step three (which I haven't figured out how to do yet) is writing an algorithm/code to output three dependent waveforms. They are 120 degrees apart (i.e. - if period is 300: first is active from period=0-100; next is active from period0 to 200; and third is active from period 0-300). This repeats indefinitely. I am using three LCD icons (in the shape of arrows) around a circle. The idea is to cycle them to show movement. Is this something that can be accomplished using single edge control? Hopefully, since I think I will be utilizing most of the PWMs. Will you point me in the direction of an example, or walk me through the process?
> > > > >
> > > > > Best Regards (and thanks again),
> > > > > Todd
> > > > >
> > > > >
> > > > >
> > > > > To: l...
> > > > > From: daniel.widyanto@
> > > > > Date: Thu, 27 Jan 2011 03:39:05 -0800
> > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Hi,
> > > > >
> > > > >
> > > > > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > > > > PWM1PCR = (0x01 << 11); //enable PWM3 as single-edge, PWM1.3 as output
> > > > > // Read Ch 24 Sec 4 for MR0 and MR3 effect on PWM1.3
> > > > > PWM1MR3 |= 1000; //half frequency..at PWM1 = 1000, PWM1.3 will be low
> > > > > PWM1MR0 |= 2000; //period...at PWM1 = 2000, PWM1.3 will be high
> > > > > PWM1LER |= 0x09; //latch MR0 and MR3 new values into PWM peripheral
> > > > > PWM1MCR = (1 << 1); // Reset PWM counter value when it reach 2000 (MR0 value)
> > > > > PWM1TCR = 0x09; //enable pwm and the shadow register
> > > > >
> > > > >
> > > > > Regards,
> > > > > -daniel
> > > > >
> > > > > --- On Tue, 1/25/11, Todd Gilbert wrote:
> > > > >
> > > > >
> > > > > From: Todd Gilbert
> > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > > To: l...
> > > > > Date: Tuesday, January 25, 2011, 2:30 PM
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > strike 2.
> > > > >
> > > > >
> > > > > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > > > > PWM1PCR |= (0x01 << 11); //enable PWM3 as output
> > > > > PWM1MRO |= 2000; //period
> > > > > PWM1MR1 |= 1000; //half period
> > > > > PWM1TCR |= 0x01; //enable pwm
> > > > > PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure about this?
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > To: l...
> > > > > From: toddgilbert@
> > > > > Date: Tue, 25 Jan 2011 14:07:44 +0000
> > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Let's set up a hypothetical. I want a single-edge triggered waveform on PWM1.3.
> > > > >
> > > > > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > > > > PWM1PCR |= (0x01 << 11); //enable PWM3 as output
> > > > > PWM1MRO |= 2000; //frequency
> > > > > PWM1MR1 |= 1000; //half frequency
> > > > > PWM1TCR |= 0x01; //enable pwm
> > > > > PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure about this?
> > > > >
> > > > > Is this right, and what else needs to be set?
> > > > >
> > > > >
> > > > >
> > > > > To: l...
> > > > > From: toddgilbert@
> > > > > Date: Tue, 25 Jan 2011 13:56:03 +0000
> > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > That's good to know. Thanks.
> > > > >
> > > > >
> > > > >
> > > > > To: l...
> > > > > From: simon.baxter@
> > > > > Date: Tue, 25 Jan 2011 13:52:20 +0000
> > > > > Subject: [lpc2000] Re: PWM Explanation
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Caution : You do need to remember though, that the |= operator reads the existing contents of PINSEL3 and ONLY sets those bits to 1 that ARE NOT already set !!! it won't clear a bit to zero !!! so it can catch you out if your changing the pin function during the code execution, i.e. from PWM1.4 to a GPIO pin.
> > > > >
> > > > > --- In l..., "simonb65" wrote:
> > > > > >
> > > > > > Todd .. Yes!
> > > > > >
> > > > > > You will usually see it the pins set individually as the program configures the separate functional areas of code ...
> > > > > >
> > > > > > PINSEL3 |= (0x2 << 10); // PWM1.3
> > > > > > PINSEL3 |= (0x2 << 14); // PWM1.4
> > > > > > etc
> > > > > >
> > > > > > or sometime you see the whole port setup in a single operation ...
> > > > > >
> > > > > > PINSEL = 0x00008800; // PWM1.3, PWM1.4, etc
> > > > > >
> > > > > > it is dependant upon how people structure the code and how small you want your end code and hardware intialization time.
> > > > > >
> > > > > > Regards,
> > > > > > Simon.
> > > > > > --- In l..., Todd Gilbert wrote:
> > > > > > >
> > > > > > >
> > > > > > > Sorry - meant PINSEL3 |= 0x2 << 10; PINSEL3 |= 0x800; and PINSEL3 |= 2048
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > From: toddgilbert@
> > > > > > > To: l...
> > > > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > > > > Date: Tue, 25 Jan 2011 13:29:53 +0000
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > okay, I think I'm catching on. If I look at PWM1.3...
> > > > > > >
> > > > > > > PINSEL3 |= 0x2 << 10; PINSEL3 |= 0x700; and PINSEL3 |= 1792 are all equivalent?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > To: l...
> > > > > > > From: tim@
> > > > > > > Date: Tue, 25 Jan 2011 12:40:50 +0000
> > > > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > ----Original Message----
> > > > > > > From: l...
> > > > > > > [mailto:l...] On Behalf Of Todd Gilbert
> > > > > > > Sent: 25 January 2011 12:16 To: l...
> > > > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > > > >
> > > > > > > > I apologize if I offended anyone - not my intent -
> > > > > > > > probably my frustration showing. BTW, I have seen the
> > > > > > > > header file and chapter 24. What I'm confused about is
> > > > > > > > how to assign values to those keywords, and when they are
> > > > > > > > necessary to reference (maybe if I see more PWM examples,
> > > > > > > > things will come together). For example, I've seen
> > > > > > > > "PINSEL3 |= (0x2 << 8)" and "PINSEL3 |= 0x20".
> > > > > > > > Meanwhile, PINSEL3 is defined in pairs (e.g. 11:10). How
> > > > > > > > is PINSEL3 |= (0x2 << 8) related to PINSEL3, pins 9:8 -
> > > > > > > > is the MSB (i.e. 9) the pin that defines PWM1.2?. I'm
> > > > > > > > not quite sure how this all works. Thanks for your help.
> > > > > > >
> > > > > > > (0x2)<<8 moves the bit pattern "10" to bit 8
> > > > > > >
> > > > > > > i.e. bit 9 will be set, bit 8 will be clear
> > > > > > >
> > > > > > > (0x03)<<8 would set both bits 9 and 8.
> > > > > > >
> > > > > > > It's written like this to make it easier to understand what the program is doing, you could equally put PINSEL3 |= 0x0100 but then it's harder to see which bits are getting set.
> > > > > > >
> > > > > > > For PINSEL, there are 2 bits for each IO pin which define what is connected to it.
> > > > > > > Normally 00 is the standard IO pin then there are 3 other settings which connect a peripheral to the pin.
> > > > > > >
> > > > > > > in the user manual section on Pin Connect Block, it tells you what these settings are.
> > > > > > >
> > > > > > > --
> > > > > > > Tim Mitchell
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
>

Reply by Todd Gilbert January 28, 20112011-01-28
Sorry - realized I forget about including PWM1MRx in the reply. Here's the complete PWM code. The question again: is there anything missing?

PINSEL3 |= (0x02 << 8); /* PWM1.2 */
PINSEL3 |= (0x02 << 14) /* PWM1.4 */
PINSEL3 |= (0x02 << 20) /* PWM1.6 */
PWM1PCR = 0x5454; /* all set up in 1 line of code */
PWM1MCR = (0x01 << 1); /* set up match control to reset on MR0 */
PWM1TCR = 0x41; /* enable TCR and PWM */
PWM1LER = 0x01; /* enable LER and latch values into PWM */

PWM1MR0 = cycle;
PWM1MR1 = 0;
PWM1MR2 = cycle*1/3;
PWM1MR3 = cycle*1/3;
PWM1MR4 = cycle*2/3;
PWM1MR5 = cycle*2/3;
PWM1MR6 = cycle;
--- In l..., "Todd Gilbert" wrote:
>
> I'm experimenting with this, to improve my understanding. Here's what I have so far - what am I excluding?.
>
> PINSEL3 |= (0x02 << 8); /* PWM1.2 */
> PINSEL3 |= (0x02 << 14) /* PWM1.4 */
> PINSEL3 |= (0x02 << 20) /* PWM1.6 */
> PWM1PCR = 0x5454; /* all set up in 1 line of code */
> PWM1MCR = (0x01 << 1); /* set up match control to reset on MR0 */
> PWM1TCR = 0x41; /* enable TCR and PWM */
> PWM1LER = 0x01; /* enable LER and latch values into PWM */
> --- In l..., "John S" wrote:
> >
> >
> > Use pins pwm1.2,pwm1.4,pwm1.6
> >
> > Use mr0 to reset tc. This sets period.
> > For your 6 edges:
> > use mr1 and mr2 to specify edges for pwm1.2
> > use mr3 and mr4 to specify edges for pwm1.4
> > use mr5 and mr6 to specify edges for pwm1.6
> >
> >
> > --- In l..., "Todd Gilbert" wrote:
> > >
> > > What if I generated the three-phase signal this way?
> > > 1) Set PWM1MR0
> > > 2) Turn on PWM1MR1 output
> > > 3) delay
> > > 4) Turn off PWM1MR1 output
> > > 5) Turn on PWM1MR2 output
> > > 6) delay
> > > 7) Turn off PWM1MR2 output
> > > 8) Turn on PWM1MR3 output
> > > 9) delay
> > > 10) Turn off PWM1MR3 output
> > > 11) go to 2
> > >
> > > It's not graceful coding, but I think it would work.
> > >
> > >
> > > --- In l..., Todd Gilbert wrote:
> > > >
> > > >
> > > > Thanks Chris,
> > > >
> > > > * Understanding how to use the PWM is step one - that is still developing.
> > > > * Step two is creating an algorithm to make a LCD icon appear to "breathe". I accomplished this by controlling the pulse width. Required a little thought, but works great.
> > > > * Step three (which I haven't figured out how to do yet) is writing an algorithm/code to output three dependent waveforms. They are 120 degrees apart (i.e. - if period is 300: first is active from period=0-100; next is active from period0 to 200; and third is active from period 0-300). This repeats indefinitely. I am using three LCD icons (in the shape of arrows) around a circle. The idea is to cycle them to show movement. Is this something that can be accomplished using single edge control? Hopefully, since I think I will be utilizing most of the PWMs. Will you point me in the direction of an example, or walk me through the process?
> > > >
> > > > Best Regards (and thanks again),
> > > > Todd
> > > >
> > > >
> > > >
> > > > To: l...
> > > > From: daniel.widyanto@
> > > > Date: Thu, 27 Jan 2011 03:39:05 -0800
> > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Hi,
> > > >
> > > >
> > > > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > > > PWM1PCR = (0x01 << 11); //enable PWM3 as single-edge, PWM1.3 as output
> > > > // Read Ch 24 Sec 4 for MR0 and MR3 effect on PWM1.3
> > > > PWM1MR3 |= 1000; //half frequency..at PWM1 = 1000, PWM1.3 will be low
> > > > PWM1MR0 |= 2000; //period...at PWM1 = 2000, PWM1.3 will be high
> > > > PWM1LER |= 0x09; //latch MR0 and MR3 new values into PWM peripheral
> > > > PWM1MCR = (1 << 1); // Reset PWM counter value when it reach 2000 (MR0 value)
> > > > PWM1TCR = 0x09; //enable pwm and the shadow register
> > > >
> > > >
> > > > Regards,
> > > > -daniel
> > > >
> > > > --- On Tue, 1/25/11, Todd Gilbert wrote:
> > > >
> > > >
> > > > From: Todd Gilbert
> > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > To: l...
> > > > Date: Tuesday, January 25, 2011, 2:30 PM
> > > >
> > > >
> > > >
> > > >
> > > > strike 2.
> > > >
> > > >
> > > > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > > > PWM1PCR |= (0x01 << 11); //enable PWM3 as output
> > > > PWM1MRO |= 2000; //period
> > > > PWM1MR1 |= 1000; //half period
> > > > PWM1TCR |= 0x01; //enable pwm
> > > > PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure about this?
> > > >
> > > >
> > > >
> > > >
> > > > To: l...
> > > > From: toddgilbert@
> > > > Date: Tue, 25 Jan 2011 14:07:44 +0000
> > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > >
> > > >
> > > >
> > > >
> > > > Let's set up a hypothetical. I want a single-edge triggered waveform on PWM1.3.
> > > >
> > > > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > > > PWM1PCR |= (0x01 << 11); //enable PWM3 as output
> > > > PWM1MRO |= 2000; //frequency
> > > > PWM1MR1 |= 1000; //half frequency
> > > > PWM1TCR |= 0x01; //enable pwm
> > > > PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure about this?
> > > >
> > > > Is this right, and what else needs to be set?
> > > >
> > > >
> > > >
> > > > To: l...
> > > > From: toddgilbert@
> > > > Date: Tue, 25 Jan 2011 13:56:03 +0000
> > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > >
> > > >
> > > >
> > > >
> > > > That's good to know. Thanks.
> > > >
> > > >
> > > >
> > > > To: l...
> > > > From: simon.baxter@
> > > > Date: Tue, 25 Jan 2011 13:52:20 +0000
> > > > Subject: [lpc2000] Re: PWM Explanation
> > > >
> > > >
> > > >
> > > >
> > > > Caution : You do need to remember though, that the |= operator reads the existing contents of PINSEL3 and ONLY sets those bits to 1 that ARE NOT already set !!! it won't clear a bit to zero !!! so it can catch you out if your changing the pin function during the code execution, i.e. from PWM1.4 to a GPIO pin.
> > > >
> > > > --- In l..., "simonb65" wrote:
> > > > >
> > > > > Todd .. Yes!
> > > > >
> > > > > You will usually see it the pins set individually as the program configures the separate functional areas of code ...
> > > > >
> > > > > PINSEL3 |= (0x2 << 10); // PWM1.3
> > > > > PINSEL3 |= (0x2 << 14); // PWM1.4
> > > > > etc
> > > > >
> > > > > or sometime you see the whole port setup in a single operation ...
> > > > >
> > > > > PINSEL = 0x00008800; // PWM1.3, PWM1.4, etc
> > > > >
> > > > > it is dependant upon how people structure the code and how small you want your end code and hardware intialization time.
> > > > >
> > > > > Regards,
> > > > > Simon.
> > > > > --- In l..., Todd Gilbert wrote:
> > > > > >
> > > > > >
> > > > > > Sorry - meant PINSEL3 |= 0x2 << 10; PINSEL3 |= 0x800; and PINSEL3 |= 2048
> > > > > >
> > > > > >
> > > > > >
> > > > > > From: toddgilbert@
> > > > > > To: l...
> > > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > > > Date: Tue, 25 Jan 2011 13:29:53 +0000
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > okay, I think I'm catching on. If I look at PWM1.3...
> > > > > >
> > > > > > PINSEL3 |= 0x2 << 10; PINSEL3 |= 0x700; and PINSEL3 |= 1792 are all equivalent?
> > > > > >
> > > > > >
> > > > > >
> > > > > > To: l...
> > > > > > From: tim@
> > > > > > Date: Tue, 25 Jan 2011 12:40:50 +0000
> > > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > ----Original Message----
> > > > > > From: l...
> > > > > > [mailto:l...] On Behalf Of Todd Gilbert
> > > > > > Sent: 25 January 2011 12:16 To: l...
> > > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > > >
> > > > > > > I apologize if I offended anyone - not my intent -
> > > > > > > probably my frustration showing. BTW, I have seen the
> > > > > > > header file and chapter 24. What I'm confused about is
> > > > > > > how to assign values to those keywords, and when they are
> > > > > > > necessary to reference (maybe if I see more PWM examples,
> > > > > > > things will come together). For example, I've seen
> > > > > > > "PINSEL3 |= (0x2 << 8)" and "PINSEL3 |= 0x20".
> > > > > > > Meanwhile, PINSEL3 is defined in pairs (e.g. 11:10). How
> > > > > > > is PINSEL3 |= (0x2 << 8) related to PINSEL3, pins 9:8 -
> > > > > > > is the MSB (i.e. 9) the pin that defines PWM1.2?. I'm
> > > > > > > not quite sure how this all works. Thanks for your help.
> > > > > >
> > > > > > (0x2)<<8 moves the bit pattern "10" to bit 8
> > > > > >
> > > > > > i.e. bit 9 will be set, bit 8 will be clear
> > > > > >
> > > > > > (0x03)<<8 would set both bits 9 and 8.
> > > > > >
> > > > > > It's written like this to make it easier to understand what the program is doing, you could equally put PINSEL3 |= 0x0100 but then it's harder to see which bits are getting set.
> > > > > >
> > > > > > For PINSEL, there are 2 bits for each IO pin which define what is connected to it.
> > > > > > Normally 00 is the standard IO pin then there are 3 other settings which connect a peripheral to the pin.
> > > > > >
> > > > > > in the user manual section on Pin Connect Block, it tells you what these settings are.
> > > > > >
> > > > > > --
> > > > > > Tim Mitchell
> > > > > >
> > > > >
> > > >
> > >
>

Reply by Todd Gilbert January 28, 20112011-01-28
I'm experimenting with this, to improve my understanding. Here's what I have so far - what am I excluding?.

PINSEL3 |= (0x02 << 8); /* PWM1.2 */
PINSEL3 |= (0x02 << 14) /* PWM1.4 */
PINSEL3 |= (0x02 << 20) /* PWM1.6 */
PWM1PCR = 0x5454; /* all set up in 1 line of code */
PWM1MCR = (0x01 << 1); /* set up match control to reset on MR0 */
PWM1TCR = 0x41; /* enable TCR and PWM */
PWM1LER = 0x01; /* enable LER and latch values into PWM */
--- In l..., "John S" wrote:
> Use pins pwm1.2,pwm1.4,pwm1.6
>
> Use mr0 to reset tc. This sets period.
> For your 6 edges:
> use mr1 and mr2 to specify edges for pwm1.2
> use mr3 and mr4 to specify edges for pwm1.4
> use mr5 and mr6 to specify edges for pwm1.6
> --- In l..., "Todd Gilbert" wrote:
> >
> > What if I generated the three-phase signal this way?
> > 1) Set PWM1MR0
> > 2) Turn on PWM1MR1 output
> > 3) delay
> > 4) Turn off PWM1MR1 output
> > 5) Turn on PWM1MR2 output
> > 6) delay
> > 7) Turn off PWM1MR2 output
> > 8) Turn on PWM1MR3 output
> > 9) delay
> > 10) Turn off PWM1MR3 output
> > 11) go to 2
> >
> > It's not graceful coding, but I think it would work.
> >
> >
> > --- In l..., Todd Gilbert wrote:
> > >
> > >
> > > Thanks Chris,
> > >
> > > * Understanding how to use the PWM is step one - that is still developing.
> > > * Step two is creating an algorithm to make a LCD icon appear to "breathe". I accomplished this by controlling the pulse width. Required a little thought, but works great.
> > > * Step three (which I haven't figured out how to do yet) is writing an algorithm/code to output three dependent waveforms. They are 120 degrees apart (i.e. - if period is 300: first is active from period=0-100; next is active from period0 to 200; and third is active from period 0-300). This repeats indefinitely. I am using three LCD icons (in the shape of arrows) around a circle. The idea is to cycle them to show movement. Is this something that can be accomplished using single edge control? Hopefully, since I think I will be utilizing most of the PWMs. Will you point me in the direction of an example, or walk me through the process?
> > >
> > > Best Regards (and thanks again),
> > > Todd
> > >
> > >
> > >
> > > To: l...
> > > From: daniel.widyanto@
> > > Date: Thu, 27 Jan 2011 03:39:05 -0800
> > > Subject: RE: [lpc2000] Re: PWM Explanation
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Hi,
> > >
> > >
> > > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > > PWM1PCR = (0x01 << 11); //enable PWM3 as single-edge, PWM1.3 as output
> > > // Read Ch 24 Sec 4 for MR0 and MR3 effect on PWM1.3
> > > PWM1MR3 |= 1000; //half frequency..at PWM1 = 1000, PWM1.3 will be low
> > > PWM1MR0 |= 2000; //period...at PWM1 = 2000, PWM1.3 will be high
> > > PWM1LER |= 0x09; //latch MR0 and MR3 new values into PWM peripheral
> > > PWM1MCR = (1 << 1); // Reset PWM counter value when it reach 2000 (MR0 value)
> > > PWM1TCR = 0x09; //enable pwm and the shadow register
> > >
> > >
> > > Regards,
> > > -daniel
> > >
> > > --- On Tue, 1/25/11, Todd Gilbert wrote:
> > >
> > >
> > > From: Todd Gilbert
> > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > To: l...
> > > Date: Tuesday, January 25, 2011, 2:30 PM
> > >
> > >
> > >
> > >
> > > strike 2.
> > >
> > >
> > > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > > PWM1PCR |= (0x01 << 11); //enable PWM3 as output
> > > PWM1MRO |= 2000; //period
> > > PWM1MR1 |= 1000; //half period
> > > PWM1TCR |= 0x01; //enable pwm
> > > PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure about this?
> > >
> > >
> > >
> > >
> > > To: l...
> > > From: toddgilbert@
> > > Date: Tue, 25 Jan 2011 14:07:44 +0000
> > > Subject: RE: [lpc2000] Re: PWM Explanation
> > >
> > >
> > >
> > >
> > > Let's set up a hypothetical. I want a single-edge triggered waveform on PWM1.3.
> > >
> > > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > > PWM1PCR |= (0x01 << 11); //enable PWM3 as output
> > > PWM1MRO |= 2000; //frequency
> > > PWM1MR1 |= 1000; //half frequency
> > > PWM1TCR |= 0x01; //enable pwm
> > > PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure about this?
> > >
> > > Is this right, and what else needs to be set?
> > >
> > >
> > >
> > > To: l...
> > > From: toddgilbert@
> > > Date: Tue, 25 Jan 2011 13:56:03 +0000
> > > Subject: RE: [lpc2000] Re: PWM Explanation
> > >
> > >
> > >
> > >
> > > That's good to know. Thanks.
> > >
> > >
> > >
> > > To: l...
> > > From: simon.baxter@
> > > Date: Tue, 25 Jan 2011 13:52:20 +0000
> > > Subject: [lpc2000] Re: PWM Explanation
> > >
> > >
> > >
> > >
> > > Caution : You do need to remember though, that the |= operator reads the existing contents of PINSEL3 and ONLY sets those bits to 1 that ARE NOT already set !!! it won't clear a bit to zero !!! so it can catch you out if your changing the pin function during the code execution, i.e. from PWM1.4 to a GPIO pin.
> > >
> > > --- In l..., "simonb65" wrote:
> > > >
> > > > Todd .. Yes!
> > > >
> > > > You will usually see it the pins set individually as the program configures the separate functional areas of code ...
> > > >
> > > > PINSEL3 |= (0x2 << 10); // PWM1.3
> > > > PINSEL3 |= (0x2 << 14); // PWM1.4
> > > > etc
> > > >
> > > > or sometime you see the whole port setup in a single operation ...
> > > >
> > > > PINSEL = 0x00008800; // PWM1.3, PWM1.4, etc
> > > >
> > > > it is dependant upon how people structure the code and how small you want your end code and hardware intialization time.
> > > >
> > > > Regards,
> > > > Simon.
> > > > --- In l..., Todd Gilbert wrote:
> > > > >
> > > > >
> > > > > Sorry - meant PINSEL3 |= 0x2 << 10; PINSEL3 |= 0x800; and PINSEL3 |= 2048
> > > > >
> > > > >
> > > > >
> > > > > From: toddgilbert@
> > > > > To: l...
> > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > > Date: Tue, 25 Jan 2011 13:29:53 +0000
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > okay, I think I'm catching on. If I look at PWM1.3...
> > > > >
> > > > > PINSEL3 |= 0x2 << 10; PINSEL3 |= 0x700; and PINSEL3 |= 1792 are all equivalent?
> > > > >
> > > > >
> > > > >
> > > > > To: l...
> > > > > From: tim@
> > > > > Date: Tue, 25 Jan 2011 12:40:50 +0000
> > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > ----Original Message----
> > > > > From: l...
> > > > > [mailto:l...] On Behalf Of Todd Gilbert
> > > > > Sent: 25 January 2011 12:16 To: l...
> > > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > >
> > > > > > I apologize if I offended anyone - not my intent -
> > > > > > probably my frustration showing. BTW, I have seen the
> > > > > > header file and chapter 24. What I'm confused about is
> > > > > > how to assign values to those keywords, and when they are
> > > > > > necessary to reference (maybe if I see more PWM examples,
> > > > > > things will come together). For example, I've seen
> > > > > > "PINSEL3 |= (0x2 << 8)" and "PINSEL3 |= 0x20".
> > > > > > Meanwhile, PINSEL3 is defined in pairs (e.g. 11:10). How
> > > > > > is PINSEL3 |= (0x2 << 8) related to PINSEL3, pins 9:8 -
> > > > > > is the MSB (i.e. 9) the pin that defines PWM1.2?. I'm
> > > > > > not quite sure how this all works. Thanks for your help.
> > > > >
> > > > > (0x2)<<8 moves the bit pattern "10" to bit 8
> > > > >
> > > > > i.e. bit 9 will be set, bit 8 will be clear
> > > > >
> > > > > (0x03)<<8 would set both bits 9 and 8.
> > > > >
> > > > > It's written like this to make it easier to understand what the program is doing, you could equally put PINSEL3 |= 0x0100 but then it's harder to see which bits are getting set.
> > > > >
> > > > > For PINSEL, there are 2 bits for each IO pin which define what is connected to it.
> > > > > Normally 00 is the standard IO pin then there are 3 other settings which connect a peripheral to the pin.
> > > > >
> > > > > in the user manual section on Pin Connect Block, it tells you what these settings are.
> > > > >
> > > > > --
> > > > > Tim Mitchell
> > > > >
> > > >
> > >
>

Reply by Todd Gilbert January 28, 20112011-01-28
Thanks for another potential solution - a lot of creativity out there. The app I'm using this for is LCD, and the design requires driving with an ac signal. I was thinking about this last night, and maybe I can use one single edge control PWM and two double edge control PWMs. The single would set up the first phase; and the two doubles would set up phase two and three. This would leave me with one PWM, that I think would cover all my remaining needs. I'll report back with my results.

To: l...
From: r...@pacbell.net
Date: Thu, 27 Jan 2011 21:47:01 +0000
Subject: [lpc2000] Re: PWM Explanation

--- In l..., Todd Gilbert wrote:
>
> This is great - thanks. However, it uses up all the PWM waveforms.
>

You can make a 'tail chaser' without using any PWM as long as the individual LEDs (LCD icons?) don't require intensity modulation. If simple binary ON/OFF will work then try this:

For 3 LEDs use the pattern
000, 100, 110, 111, 111, 011, 001, 000

Use a timer interrupt to change from one pattern to another.

Richard
Reply by rtstofer January 27, 20112011-01-27
--- In l..., Todd Gilbert wrote:
>
> This is great - thanks. However, it uses up all the PWM waveforms.
>

You can make a 'tail chaser' without using any PWM as long as the individual LEDs (LCD icons?) don't require intensity modulation. If simple binary ON/OFF will work then try this:

For 3 LEDs use the pattern
000, 100, 110, 111, 111, 011, 001, 000

Use a timer interrupt to change from one pattern to another.

Richard

Reply by Todd Gilbert January 27, 20112011-01-27
This is great - thanks. However, it uses up all the PWM waveforms.

To: l...
From: s...@ptmelec.com
Date: Thu, 27 Jan 2011 18:44:21 +0000
Subject: [lpc2000] Re: PWM Explanation

Use pins pwm1.2,pwm1.4,pwm1.6

Use mr0 to reset tc. This sets period.
For your 6 edges:
use mr1 and mr2 to specify edges for pwm1.2
use mr3 and mr4 to specify edges for pwm1.4
use mr5 and mr6 to specify edges for pwm1.6

--- In l..., "Todd Gilbert" wrote:
>
> What if I generated the three-phase signal this way?
> 1) Set PWM1MR0
> 2) Turn on PWM1MR1 output
> 3) delay
> 4) Turn off PWM1MR1 output
> 5) Turn on PWM1MR2 output
> 6) delay
> 7) Turn off PWM1MR2 output
> 8) Turn on PWM1MR3 output
> 9) delay
> 10) Turn off PWM1MR3 output
> 11) go to 2
>
> It's not graceful coding, but I think it would work.
> --- In l..., Todd Gilbert wrote:
> >
> >
> > Thanks Chris,
> >
> > * Understanding how to use the PWM is step one - that is still developing.
> > * Step two is creating an algorithm to make a LCD icon appear to "breathe". I accomplished this by controlling the pulse width. Required a little thought, but works great.
> > * Step three (which I haven't figured out how to do yet) is writing an algorithm/code to output three dependent waveforms. They are 120 degrees apart (i.e. - if period is 300: first is active from period=0-100; next is active from period0 to 200; and third is active from period 0-300). This repeats indefinitely. I am using three LCD icons (in the shape of arrows) around a circle. The idea is to cycle them to show movement. Is this something that can be accomplished using single edge control? Hopefully, since I think I will be utilizing most of the PWMs. Will you point me in the direction of an example, or walk me through the process?
> >
> > Best Regards (and thanks again),
> > Todd
> >
> >
> >
> > To: l...
> > From: daniel.widyanto@
> > Date: Thu, 27 Jan 2011 03:39:05 -0800
> > Subject: RE: [lpc2000] Re: PWM Explanation
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Hi,
> >
> >
> > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > PWM1PCR = (0x01 << 11); //enable PWM3 as single-edge, PWM1.3 as output
> > // Read Ch 24 Sec 4 for MR0 and MR3 effect on PWM1.3
> > PWM1MR3 |= 1000; //half frequency..at PWM1 = 1000, PWM1.3 will be low
> > PWM1MR0 |= 2000; //period...at PWM1 = 2000, PWM1.3 will be high
> > PWM1LER |= 0x09; //latch MR0 and MR3 new values into PWM peripheral
> > PWM1MCR = (1 << 1); // Reset PWM counter value when it reach 2000 (MR0 value)
> > PWM1TCR = 0x09; //enable pwm and the shadow register
> >
> >
> > Regards,
> > -daniel
> >
> > --- On Tue, 1/25/11, Todd Gilbert wrote:
> >
> >
> > From: Todd Gilbert
> > Subject: RE: [lpc2000] Re: PWM Explanation
> > To: l...
> > Date: Tuesday, January 25, 2011, 2:30 PM
> >
> >
> >
> >
> > strike 2.
> >
> >
> > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > PWM1PCR |= (0x01 << 11); //enable PWM3 as output
> > PWM1MRO |= 2000; //period
> > PWM1MR1 |= 1000; //half period
> > PWM1TCR |= 0x01; //enable pwm
> > PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure about this?
> >
> >
> >
> >
> > To: l...
> > From: toddgilbert@
> > Date: Tue, 25 Jan 2011 14:07:44 +0000
> > Subject: RE: [lpc2000] Re: PWM Explanation
> >
> >
> >
> >
> > Let's set up a hypothetical. I want a single-edge triggered waveform on PWM1.3.
> >
> > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > PWM1PCR |= (0x01 << 11); //enable PWM3 as output
> > PWM1MRO |= 2000; //frequency
> > PWM1MR1 |= 1000; //half frequency
> > PWM1TCR |= 0x01; //enable pwm
> > PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure about this?
> >
> > Is this right, and what else needs to be set?
> >
> >
> >
> > To: l...
> > From: toddgilbert@
> > Date: Tue, 25 Jan 2011 13:56:03 +0000
> > Subject: RE: [lpc2000] Re: PWM Explanation
> >
> >
> >
> >
> > That's good to know. Thanks.
> >
> >
> >
> > To: l...
> > From: simon.baxter@
> > Date: Tue, 25 Jan 2011 13:52:20 +0000
> > Subject: [lpc2000] Re: PWM Explanation
> >
> >
> >
> >
> > Caution : You do need to remember though, that the |= operator reads the existing contents of PINSEL3 and ONLY sets those bits to 1 that ARE NOT already set !!! it won't clear a bit to zero !!! so it can catch you out if your changing the pin function during the code execution, i.e. from PWM1.4 to a GPIO pin.
> >
> > --- In l..., "simonb65" wrote:
> > >
> > > Todd .. Yes!
> > >
> > > You will usually see it the pins set individually as the program configures the separate functional areas of code ...
> > >
> > > PINSEL3 |= (0x2 << 10); // PWM1.3
> > > PINSEL3 |= (0x2 << 14); // PWM1.4
> > > etc
> > >
> > > or sometime you see the whole port setup in a single operation ...
> > >
> > > PINSEL = 0x00008800; // PWM1.3, PWM1.4, etc
> > >
> > > it is dependant upon how people structure the code and how small you want your end code and hardware intialization time.
> > >
> > > Regards,
> > > Simon.
> > > --- In l..., Todd Gilbert wrote:
> > > >
> > > >
> > > > Sorry - meant PINSEL3 |= 0x2 << 10; PINSEL3 |= 0x800; and PINSEL3 |= 2048
> > > >
> > > >
> > > >
> > > > From: toddgilbert@
> > > > To: l...
> > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > Date: Tue, 25 Jan 2011 13:29:53 +0000
> > > >
> > > >
> > > >
> > > >
> > > > okay, I think I'm catching on. If I look at PWM1.3...
> > > >
> > > > PINSEL3 |= 0x2 << 10; PINSEL3 |= 0x700; and PINSEL3 |= 1792 are all equivalent?
> > > >
> > > >
> > > >
> > > > To: l...
> > > > From: tim@
> > > > Date: Tue, 25 Jan 2011 12:40:50 +0000
> > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > >
> > > >
> > > >
> > > >
> > > > ----Original Message----
> > > > From: l...
> > > > [mailto:l...] On Behalf Of Todd Gilbert
> > > > Sent: 25 January 2011 12:16 To: l...
> > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > >
> > > > > I apologize if I offended anyone - not my intent -
> > > > > probably my frustration showing. BTW, I have seen the
> > > > > header file and chapter 24. What I'm confused about is
> > > > > how to assign values to those keywords, and when they are
> > > > > necessary to reference (maybe if I see more PWM examples,
> > > > > things will come together). For example, I've seen
> > > > > "PINSEL3 |= (0x2 << 8)" and "PINSEL3 |= 0x20".
> > > > > Meanwhile, PINSEL3 is defined in pairs (e.g. 11:10). How
> > > > > is PINSEL3 |= (0x2 << 8) related to PINSEL3, pins 9:8 -
> > > > > is the MSB (i.e. 9) the pin that defines PWM1.2?. I'm
> > > > > not quite sure how this all works. Thanks for your help.
> > > >
> > > > (0x2)<<8 moves the bit pattern "10" to bit 8
> > > >
> > > > i.e. bit 9 will be set, bit 8 will be clear
> > > >
> > > > (0x03)<<8 would set both bits 9 and 8.
> > > >
> > > > It's written like this to make it easier to understand what the program is doing, you could equally put PINSEL3 |= 0x0100 but then it's harder to see which bits are getting set.
> > > >
> > > > For PINSEL, there are 2 bits for each IO pin which define what is connected to it.
> > > > Normally 00 is the standard IO pin then there are 3 other settings which connect a peripheral to the pin.
> > > >
> > > > in the user manual section on Pin Connect Block, it tells you what these settings are.
> > > >
> > > > --
> > > > Tim Mitchell
> > > >
> > >
>
Reply by John S January 27, 20112011-01-27
Use pins pwm1.2,pwm1.4,pwm1.6

Use mr0 to reset tc. This sets period.
For your 6 edges:
use mr1 and mr2 to specify edges for pwm1.2
use mr3 and mr4 to specify edges for pwm1.4
use mr5 and mr6 to specify edges for pwm1.6
--- In l..., "Todd Gilbert" wrote:
>
> What if I generated the three-phase signal this way?
> 1) Set PWM1MR0
> 2) Turn on PWM1MR1 output
> 3) delay
> 4) Turn off PWM1MR1 output
> 5) Turn on PWM1MR2 output
> 6) delay
> 7) Turn off PWM1MR2 output
> 8) Turn on PWM1MR3 output
> 9) delay
> 10) Turn off PWM1MR3 output
> 11) go to 2
>
> It's not graceful coding, but I think it would work.
> --- In l..., Todd Gilbert wrote:
> >
> >
> > Thanks Chris,
> >
> > * Understanding how to use the PWM is step one - that is still developing.
> > * Step two is creating an algorithm to make a LCD icon appear to "breathe". I accomplished this by controlling the pulse width. Required a little thought, but works great.
> > * Step three (which I haven't figured out how to do yet) is writing an algorithm/code to output three dependent waveforms. They are 120 degrees apart (i.e. - if period is 300: first is active from period=0-100; next is active from period0 to 200; and third is active from period 0-300). This repeats indefinitely. I am using three LCD icons (in the shape of arrows) around a circle. The idea is to cycle them to show movement. Is this something that can be accomplished using single edge control? Hopefully, since I think I will be utilizing most of the PWMs. Will you point me in the direction of an example, or walk me through the process?
> >
> > Best Regards (and thanks again),
> > Todd
> >
> >
> >
> > To: l...
> > From: daniel.widyanto@
> > Date: Thu, 27 Jan 2011 03:39:05 -0800
> > Subject: RE: [lpc2000] Re: PWM Explanation
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Hi,
> >
> >
> > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > PWM1PCR = (0x01 << 11); //enable PWM3 as single-edge, PWM1.3 as output
> > // Read Ch 24 Sec 4 for MR0 and MR3 effect on PWM1.3
> > PWM1MR3 |= 1000; //half frequency..at PWM1 = 1000, PWM1.3 will be low
> > PWM1MR0 |= 2000; //period...at PWM1 = 2000, PWM1.3 will be high
> > PWM1LER |= 0x09; //latch MR0 and MR3 new values into PWM peripheral
> > PWM1MCR = (1 << 1); // Reset PWM counter value when it reach 2000 (MR0 value)
> > PWM1TCR = 0x09; //enable pwm and the shadow register
> >
> >
> > Regards,
> > -daniel
> >
> > --- On Tue, 1/25/11, Todd Gilbert wrote:
> >
> >
> > From: Todd Gilbert
> > Subject: RE: [lpc2000] Re: PWM Explanation
> > To: l...
> > Date: Tuesday, January 25, 2011, 2:30 PM
> >
> >
> >
> >
> > strike 2.
> >
> >
> > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > PWM1PCR |= (0x01 << 11); //enable PWM3 as output
> > PWM1MRO |= 2000; //period
> > PWM1MR1 |= 1000; //half period
> > PWM1TCR |= 0x01; //enable pwm
> > PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure about this?
> >
> >
> >
> >
> > To: l...
> > From: toddgilbert@
> > Date: Tue, 25 Jan 2011 14:07:44 +0000
> > Subject: RE: [lpc2000] Re: PWM Explanation
> >
> >
> >
> >
> > Let's set up a hypothetical. I want a single-edge triggered waveform on PWM1.3.
> >
> > PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> > PWM1PCR |= (0x01 << 11); //enable PWM3 as output
> > PWM1MRO |= 2000; //frequency
> > PWM1MR1 |= 1000; //half frequency
> > PWM1TCR |= 0x01; //enable pwm
> > PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure about this?
> >
> > Is this right, and what else needs to be set?
> >
> >
> >
> > To: l...
> > From: toddgilbert@
> > Date: Tue, 25 Jan 2011 13:56:03 +0000
> > Subject: RE: [lpc2000] Re: PWM Explanation
> >
> >
> >
> >
> > That's good to know. Thanks.
> >
> >
> >
> > To: l...
> > From: simon.baxter@
> > Date: Tue, 25 Jan 2011 13:52:20 +0000
> > Subject: [lpc2000] Re: PWM Explanation
> >
> >
> >
> >
> > Caution : You do need to remember though, that the |= operator reads the existing contents of PINSEL3 and ONLY sets those bits to 1 that ARE NOT already set !!! it won't clear a bit to zero !!! so it can catch you out if your changing the pin function during the code execution, i.e. from PWM1.4 to a GPIO pin.
> >
> > --- In l..., "simonb65" wrote:
> > >
> > > Todd .. Yes!
> > >
> > > You will usually see it the pins set individually as the program configures the separate functional areas of code ...
> > >
> > > PINSEL3 |= (0x2 << 10); // PWM1.3
> > > PINSEL3 |= (0x2 << 14); // PWM1.4
> > > etc
> > >
> > > or sometime you see the whole port setup in a single operation ...
> > >
> > > PINSEL = 0x00008800; // PWM1.3, PWM1.4, etc
> > >
> > > it is dependant upon how people structure the code and how small you want your end code and hardware intialization time.
> > >
> > > Regards,
> > > Simon.
> > > --- In l..., Todd Gilbert wrote:
> > > >
> > > >
> > > > Sorry - meant PINSEL3 |= 0x2 << 10; PINSEL3 |= 0x800; and PINSEL3 |= 2048
> > > >
> > > >
> > > >
> > > > From: toddgilbert@
> > > > To: l...
> > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > > Date: Tue, 25 Jan 2011 13:29:53 +0000
> > > >
> > > >
> > > >
> > > >
> > > > okay, I think I'm catching on. If I look at PWM1.3...
> > > >
> > > > PINSEL3 |= 0x2 << 10; PINSEL3 |= 0x700; and PINSEL3 |= 1792 are all equivalent?
> > > >
> > > >
> > > >
> > > > To: l...
> > > > From: tim@
> > > > Date: Tue, 25 Jan 2011 12:40:50 +0000
> > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > >
> > > >
> > > >
> > > >
> > > > ----Original Message----
> > > > From: l...
> > > > [mailto:l...] On Behalf Of Todd Gilbert
> > > > Sent: 25 January 2011 12:16 To: l...
> > > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > >
> > > > > I apologize if I offended anyone - not my intent -
> > > > > probably my frustration showing. BTW, I have seen the
> > > > > header file and chapter 24. What I'm confused about is
> > > > > how to assign values to those keywords, and when they are
> > > > > necessary to reference (maybe if I see more PWM examples,
> > > > > things will come together). For example, I've seen
> > > > > "PINSEL3 |= (0x2 << 8)" and "PINSEL3 |= 0x20".
> > > > > Meanwhile, PINSEL3 is defined in pairs (e.g. 11:10). How
> > > > > is PINSEL3 |= (0x2 << 8) related to PINSEL3, pins 9:8 -
> > > > > is the MSB (i.e. 9) the pin that defines PWM1.2?. I'm
> > > > > not quite sure how this all works. Thanks for your help.
> > > >
> > > > (0x2)<<8 moves the bit pattern "10" to bit 8
> > > >
> > > > i.e. bit 9 will be set, bit 8 will be clear
> > > >
> > > > (0x03)<<8 would set both bits 9 and 8.
> > > >
> > > > It's written like this to make it easier to understand what the program is doing, you could equally put PINSEL3 |= 0x0100 but then it's harder to see which bits are getting set.
> > > >
> > > > For PINSEL, there are 2 bits for each IO pin which define what is connected to it.
> > > > Normally 00 is the standard IO pin then there are 3 other settings which connect a peripheral to the pin.
> > > >
> > > > in the user manual section on Pin Connect Block, it tells you what these settings are.
> > > >
> > > > --
> > > > Tim Mitchell
> > > >
> > >
>

Reply by Todd Gilbert January 27, 20112011-01-27
What if I generated the three-phase signal this way?
1) Set PWM1MR0
2) Turn on PWM1MR1 output
3) delay
4) Turn off PWM1MR1 output
5) Turn on PWM1MR2 output
6) delay
7) Turn off PWM1MR2 output
8) Turn on PWM1MR3 output
9) delay
10) Turn off PWM1MR3 output
11) go to 2

It's not graceful coding, but I think it would work.
--- In l..., Todd Gilbert wrote:
> Thanks Chris,
>
> * Understanding how to use the PWM is step one - that is still developing.
> * Step two is creating an algorithm to make a LCD icon appear to "breathe". I accomplished this by controlling the pulse width. Required a little thought, but works great.
> * Step three (which I haven't figured out how to do yet) is writing an algorithm/code to output three dependent waveforms. They are 120 degrees apart (i.e. - if period is 300: first is active from period=0-100; next is active from period0 to 200; and third is active from period 0-300). This repeats indefinitely. I am using three LCD icons (in the shape of arrows) around a circle. The idea is to cycle them to show movement. Is this something that can be accomplished using single edge control? Hopefully, since I think I will be utilizing most of the PWMs. Will you point me in the direction of an example, or walk me through the process?
>
> Best Regards (and thanks again),
> Todd
>
> To: l...
> From: daniel.widyanto@...
> Date: Thu, 27 Jan 2011 03:39:05 -0800
> Subject: RE: [lpc2000] Re: PWM Explanation
>
>
> Hi,
> PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> PWM1PCR = (0x01 << 11); //enable PWM3 as single-edge, PWM1.3 as output
> // Read Ch 24 Sec 4 for MR0 and MR3 effect on PWM1.3
> PWM1MR3 |= 1000; //half frequency..at PWM1 = 1000, PWM1.3 will be low
> PWM1MR0 |= 2000; //period...at PWM1 = 2000, PWM1.3 will be high
> PWM1LER |= 0x09; //latch MR0 and MR3 new values into PWM peripheral
> PWM1MCR = (1 << 1); // Reset PWM counter value when it reach 2000 (MR0 value)
> PWM1TCR = 0x09; //enable pwm and the shadow register
> Regards,
> -daniel
>
> --- On Tue, 1/25/11, Todd Gilbert wrote:
> From: Todd Gilbert
> Subject: RE: [lpc2000] Re: PWM Explanation
> To: l...
> Date: Tuesday, January 25, 2011, 2:30 PM
> strike 2.
>
>
> PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> PWM1PCR |= (0x01 << 11); //enable PWM3 as output
> PWM1MRO |= 2000; //period
> PWM1MR1 |= 1000; //half period
> PWM1TCR |= 0x01; //enable pwm
> PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure about this?
>
>
> To: l...
> From: toddgilbert@...
> Date: Tue, 25 Jan 2011 14:07:44 +0000
> Subject: RE: [lpc2000] Re: PWM Explanation
>
>
> Let's set up a hypothetical. I want a single-edge triggered waveform on PWM1.3.
>
> PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21
> PWM1PCR |= (0x01 << 11); //enable PWM3 as output
> PWM1MRO |= 2000; //frequency
> PWM1MR1 |= 1000; //half frequency
> PWM1TCR |= 0x01; //enable pwm
> PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure about this?
>
> Is this right, and what else needs to be set?
>
> To: l...
> From: toddgilbert@...
> Date: Tue, 25 Jan 2011 13:56:03 +0000
> Subject: RE: [lpc2000] Re: PWM Explanation
>
>
> That's good to know. Thanks.
>
> To: l...
> From: simon.baxter@...
> Date: Tue, 25 Jan 2011 13:52:20 +0000
> Subject: [lpc2000] Re: PWM Explanation
>
>
> Caution : You do need to remember though, that the |= operator reads the existing contents of PINSEL3 and ONLY sets those bits to 1 that ARE NOT already set !!! it won't clear a bit to zero !!! so it can catch you out if your changing the pin function during the code execution, i.e. from PWM1.4 to a GPIO pin.
>
> --- In l..., "simonb65" wrote:
> >
> > Todd .. Yes!
> >
> > You will usually see it the pins set individually as the program configures the separate functional areas of code ...
> >
> > PINSEL3 |= (0x2 << 10); // PWM1.3
> > PINSEL3 |= (0x2 << 14); // PWM1.4
> > etc
> >
> > or sometime you see the whole port setup in a single operation ...
> >
> > PINSEL = 0x00008800; // PWM1.3, PWM1.4, etc
> >
> > it is dependant upon how people structure the code and how small you want your end code and hardware intialization time.
> >
> > Regards,
> > Simon.
> > --- In l..., Todd Gilbert wrote:
> > >
> > >
> > > Sorry - meant PINSEL3 |= 0x2 << 10; PINSEL3 |= 0x800; and PINSEL3 |= 2048
> > >
> > >
> > >
> > > From: toddgilbert@
> > > To: l...
> > > Subject: RE: [lpc2000] Re: PWM Explanation
> > > Date: Tue, 25 Jan 2011 13:29:53 +0000
> > >
> > >
> > >
> > >
> > > okay, I think I'm catching on. If I look at PWM1.3...
> > >
> > > PINSEL3 |= 0x2 << 10; PINSEL3 |= 0x700; and PINSEL3 |= 1792 are all equivalent?
> > >
> > >
> > >
> > > To: l...
> > > From: tim@
> > > Date: Tue, 25 Jan 2011 12:40:50 +0000
> > > Subject: RE: [lpc2000] Re: PWM Explanation
> > >
> > >
> > >
> > >
> > > ----Original Message----
> > > From: l...
> > > [mailto:l...] On Behalf Of Todd Gilbert
> > > Sent: 25 January 2011 12:16 To: l...
> > > Subject: RE: [lpc2000] Re: PWM Explanation
> > >
> > > > I apologize if I offended anyone - not my intent -
> > > > probably my frustration showing. BTW, I have seen the
> > > > header file and chapter 24. What I'm confused about is
> > > > how to assign values to those keywords, and when they are
> > > > necessary to reference (maybe if I see more PWM examples,
> > > > things will come together). For example, I've seen
> > > > "PINSEL3 |= (0x2 << 8)" and "PINSEL3 |= 0x20".
> > > > Meanwhile, PINSEL3 is defined in pairs (e.g. 11:10). How
> > > > is PINSEL3 |= (0x2 << 8) related to PINSEL3, pins 9:8 -
> > > > is the MSB (i.e. 9) the pin that defines PWM1.2?. I'm
> > > > not quite sure how this all works. Thanks for your help.
> > >
> > > (0x2)<<8 moves the bit pattern "10" to bit 8
> > >
> > > i.e. bit 9 will be set, bit 8 will be clear
> > >
> > > (0x03)<<8 would set both bits 9 and 8.
> > >
> > > It's written like this to make it easier to understand what the program is doing, you could equally put PINSEL3 |= 0x0100 but then it's harder to see which bits are getting set.
> > >
> > > For PINSEL, there are 2 bits for each IO pin which define what is connected to it.
> > > Normally 00 is the standard IO pin then there are 3 other settings which connect a peripheral to the pin.
> > >
> > > in the user manual section on Pin Connect Block, it tells you what these settings are.
> > >
> > > --
> > > Tim Mitchell
> > >
>