EmbeddedRelated.com
Forums

PWM Explanation

Started by todd...@hotmail.com January 24, 2011
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
>

An Engineer's Guide to the LPC2100 Series

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
>

That's good to know. Thanks.

To: l...
From: s...@accutest.co.uk
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
>
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: t...@hotmail.com
Date: Tue, 25 Jan 2011 13:56:03 +0000
Subject: RE: [lpc2000] Re: PWM Explanation

That's good to know. Thanks.

To: l...
From: s...@accutest.co.uk
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
>
Yes, to ensure you get what you expected you should set them both to zero first using &=~ (bitwise invert)

PINSEL3 &= ~(0x03<<10); //ensures both bits 10+11 are 0
PINSEL3 |= 0x02<<10; //sets the bits you wanted

--
Tim Mitchell

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: t...@hotmail.com
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: t...@hotmail.com
Date: Tue, 25 Jan 2011 13:56:03 +0000
Subject: RE: [lpc2000] Re: PWM Explanation

That's good to know. Thanks.

To: l...
From: s...@accutest.co.uk
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
>
In case you didn't follow the thread...

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; //period
PWM1MR1 |= 1000; //half period
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?
--- In l..., "Tim Mitchell" wrote:
>
> Yes, to ensure you get what you expected you should set them both to zero first using &=~ (bitwise invert)
>
> PINSEL3 &= ~(0x03<<10); //ensures both bits 10+11 are 0
> PINSEL3 |= 0x02<<10; //sets the bits you wanted
>
> --
> Tim Mitchell
>

----Original Message----
From: l...
[mailto:l...] On Behalf Of Todd Gilbert
Sent: 25 January 2011 15:50 To: l...
Subject: [lpc2000] Re: PWM Explanation

> In case you didn't follow the thread...
>
> 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; //period
> PWM1MR1 |= 1000; //half period
> PWM1TCR |= 0x01; //enable pwm
> PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure
> about this?
>

Hi Todd, I've never actually done anything with the PWM on this chip, I was just explaining the bit shifting notation, so I am not sure if your settings above are right or not.
--
Tim Mitchell

Thanks for getting me started.

To: l...
From: t...@sabretechnology.co.uk
Date: Tue, 25 Jan 2011 16:20:30 +0000
Subject: RE: [lpc2000] Re: PWM Explanation

----Original Message----
From: l...
[mailto:l...] On Behalf Of Todd Gilbert
Sent: 25 January 2011 15:50 To: l...
Subject: [lpc2000] Re: PWM Explanation

> In case you didn't follow the thread...
>
> 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; //period
> PWM1MR1 |= 1000; //half period
> PWM1TCR |= 0x01; //enable pwm
> PWM1LER |= 0x04; //enable PWM Match 0 latch - not sure
> about this?
>

Hi Todd, I've never actually done anything with the PWM on this chip, I was just explaining the bit shifting notation, so I am not sure if your settings above are right or not.

--
Tim Mitchell
Hi,
PINSEL3 |= (0x02 << 10); //PWM1.3 = P1.21PWM1PCR = (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 lowPWM1MR0 |= 2000; //period...at PWM1 = 2000, PWM1.3 will be highPWM1LER |= 0x09; //latch MR0 and MR3 new values into PWM peripheralPWM1MCR = (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: t...@hotmail.com
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 beset?

To: l...
From: t...@hotmail.com
Date: Tue, 25 Jan 2011 13:56:03 +0000
Subject: RE: [lpc2000] Re: PWM Explanation


That's good to know. Thanks.

To: l...
From: s...@accutest.co.uk
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
>

#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-mkp
{border:1px solid #d8d8d8;font-family:Arial;padding:0 10px;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-mkp hr
{border:1px solid #d8d8d8;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-mkp #yiv505687781ecxhd
{color:#628c2a;font-size:85%;font-weight:700;line-height:122%;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-mkp #yiv505687781ecxads
{margin-bottom:10px;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-mkp .yiv505687781ecxad
{padding:0 0;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-mkp .yiv505687781ecxad p
{}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-mkp .yiv505687781ecxad a
{color:#0000ff;text-decoration:none;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-sponsor #yiv505687781ecxygrp-lc
{font-family:Arial;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-sponsor #yiv505687781ecxygrp-lc #yiv505687781ecxhd
{font-weight:700;font-size:78%;line-height:122%;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-sponsor #yiv505687781ecxygrp-lc .yiv505687781ecxad
{margin-bottom:10px;padding:0 0;}
#yiv505687781 .yiv505687781ExternalClass a
{color:#1e66ae;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxactions
{font-family:Verdana;font-size:11px;padding:10px 0;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxactivity
{background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxactivity span
{font-weight:700;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxactivity span a
{color:#5085b6;text-decoration:none;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxactivity span span
{color:#ff7900;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxactivity span .yiv505687781ecxunderline
{text-decoration:underline;}
#yiv505687781 .yiv505687781ExternalClass .yiv505687781ecxattach
{clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}
#yiv505687781 .yiv505687781ExternalClass .yiv505687781ecxattach div a
{text-decoration:none;}
#yiv505687781 .yiv505687781ExternalClass .yiv505687781ecxattach img
{border:none;padding-right:5px;}
#yiv505687781 .yiv505687781ExternalClass .yiv505687781ecxattach label
{display:block;margin-bottom:5px;}
#yiv505687781 .yiv505687781ExternalClass .yiv505687781ecxattach label a
{text-decoration:none;}
#yiv505687781 .yiv505687781ExternalClass blockquote
{}
#yiv505687781 .yiv505687781ExternalClass .yiv505687781ecxbold
{font-family:Arial;font-size:13px;font-weight:700;}
#yiv505687781 .yiv505687781ExternalClass .yiv505687781ecxbold a
{text-decoration:none;}
#yiv505687781 .yiv505687781ExternalClass dd.yiv505687781ecxlast p a
{font-family:Verdana;font-weight:700;}
#yiv505687781 .yiv505687781ExternalClass dd.yiv505687781ecxlast p span
{margin-right:10px;font-family:Verdana;font-weight:700;}
#yiv505687781 .yiv505687781ExternalClass dd.yiv505687781ecxlast p span.yiv505687781ecxyshortcuts
{margin-right:0;}
#yiv505687781 .yiv505687781ExternalClass div.yiv505687781ecxattach-table div div a
{text-decoration:none;}
#yiv505687781 .yiv505687781ExternalClass div.yiv505687781ecxattach-table
{width:400px;}
#yiv505687781 .yiv505687781ExternalClass div.yiv505687781ecxfile-title a, #yiv505687781 .yiv505687781ExternalClass div.yiv505687781ecxfile-title a:active, #yiv505687781 .yiv505687781ExternalClass div.yiv505687781ecxfile-title a:hover, #yiv505687781 .yiv505687781ExternalClass div.yiv505687781ecxfile-title a:visited
{text-decoration:none;}
#yiv505687781 .yiv505687781ExternalClass div.yiv505687781ecxphoto-title a, #yiv505687781 .yiv505687781ExternalClass div.yiv505687781ecxphoto-title a:active, #yiv505687781 .yiv505687781ExternalClass div.yiv505687781ecxphoto-title a:hover, #yiv505687781 .yiv505687781ExternalClass div.yiv505687781ecxphoto-title a:visited
{text-decoration:none;}
#yiv505687781 .yiv505687781ExternalClass ecxdiv#yiv505687781ygrp-mlmsg #yiv505687781ecxygrp-msg p a span.yiv505687781ecxyshortcuts
{font-family:Verdana;font-size:10px;font-weight:normal;}
#yiv505687781 .yiv505687781ExternalClass .yiv505687781ecxgreen
{color:#628c2a;}
#yiv505687781 .yiv505687781ExternalClass .yiv505687781ecxMsoNormal
{}
#yiv505687781 .yiv505687781ExternalClass ecxo
{font-size:0;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxphotos div
{float:left;width:72px;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxphotos div div
{border:1px solid #666666;height:62px;overflow:hidden;width:62px;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxphotos div label
{color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxreco-category
{font-size:77%;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxreco-desc
{font-size:77%;}
#yiv505687781 .yiv505687781ExternalClass .yiv505687781ecxreplbq
{}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-mlmsg
{font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-mlmsg table
{font-size:inherit;font:100%;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-mlmsg select, #yiv505687781 .yiv505687781ExternalClass input, #yiv505687781 .yiv505687781ExternalClass textarea
{font:99% Arial, Helvetica, clean, sans-serif;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-mlmsg pre, #yiv505687781 .yiv505687781ExternalClass code
{font:115% monospace;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-mlmsg ecx*
{line-height:1.22em;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-mlmsg #yiv505687781ecxlogo
{padding-bottom:10px;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-mlmsg a
{color:#1E66AE;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-msg p a
{font-family:Verdana;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-msg ecxp#yiv505687781attach-count span
{color:#1E66AE;font-weight:700;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-reco #yiv505687781ecxreco-head
{color:#ff7900;font-weight:700;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-reco
{margin-bottom:20px;padding:0px;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-sponsor #yiv505687781ecxov li a
{font-size:130%;text-decoration:none;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-sponsor #yiv505687781ecxov li
{font-size:77%;list-style-type:square;padding:6px 0;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-sponsor #yiv505687781ecxov ul
{padding:0 0 0 8px;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-text
{font-family:Georgia;}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-text p
{}
#yiv505687781 .yiv505687781ExternalClass #yiv505687781ecxygrp-text tt
{font-size:120%;}