EmbeddedRelated.com
Forums

LPC2368 reliable operation

Started by Hossein April 4, 2011
Hi all,
I am new to ARM processors and designed a custom board with LPC2368FBD100, I have written a very simple code in keil software which simply turns on two LEDs and turns off two others which I designed in my custom board and intend to use them as indicators (P2.19 -> P2.22) when I download my code to the board - I am using H-Jtag and wiggler LPT cable- I see that my microcontroller oscillator pin is oscillating but no change on the LEDs happens ?!! one strange behavior on these pins is that the voltage level is always -before and after programing -
around 2.25V while other GPIOs which I used for other purposes are 3.3V
-for example push bottons - I tried to change PLL divider and multiplyer values in config wizard of assembly startup file but it doesn't have any effects.
here is the code :

#include /* LPC23xx definitions */
int main(void){
PINSEL3 &= 0XFFFFC03F; //Config LEDs as GPIO pins however their reset value chooses GPIO
//// PINMODE3 &= 0XFFFFC03F; // Enables Pull ups on P1.19 to P1.22 pins
FIO1DIR |= 0X00780000; //Enhanced GPIO Function Registers
while(1){
FIO1SET |= 0X00600000;
FIO1CLR |= 0X00180000;

FIO1SET |= 0X00180000;
FIO1CLR |= 0X00600000;
}
}

can anybody help me?

thanks in advance.

An Engineer's Guide to the LPC2100 Series

To use the Fast GPIO you have to enable it first,

SCS |=1; /* enable high speed gpio */

Alex

----- Original Message -----
From: Hossein
To: l...
Sent: Monday, April 04, 2011 9:57 PM
Subject: [lpc2000] LPC2368 reliable operation

Hi all,
I am new to ARM processors and designed a custom board with LPC2368FBD100, I have written a very simple code in keil software which simply turns on two LEDs and turns off two others which I designed in my custom board and intend to use them as indicators (P2.19 -> P2.22) when I download my code to the board - I am using H-Jtag and wiggler LPT cable- I see that my microcontroller oscillator pin is oscillating but no change on the LEDs happens ?!! one strange behavior on these pins is that the voltage level is always -before and after programing -
around 2.25V while other GPIOs which I used for other purposes are 3.3V
-for example push bottons - I tried to change PLL divider and multiplyer values in config wizard of assembly startup file but it doesn't have any effects.
here is the code :

#include /* LPC23xx definitions */

int main(void){
PINSEL3 &= 0XFFFFC03F; //Config LEDs as GPIO pins however their reset value chooses GPIO
//// PINMODE3 &= 0XFFFFC03F; // Enables Pull ups on P1.19 to P1.22 pins
FIO1DIR |= 0X00780000; //Enhanced GPIO Function Registers
while(1){
FIO1SET |= 0X00600000;
FIO1CLR |= 0X00180000;

FIO1SET |= 0X00180000;
FIO1CLR |= 0X00600000;
}
}

can anybody help me?

thanks in advance.
And you also need to use some delay between led on/off to be able to slow it down and see it.
You can use a for loop

int d;

for (d = 0; d < 1000000; d++);

----- Original Message -----
From: Alex
To: l...
Sent: Monday, April 04, 2011 11:43 PM
Subject: Re: [lpc2000] LPC2368 reliable operation

To use the Fast GPIO you have to enable it first,

SCS |=1; /* enable high speed gpio */

Alex

----- Original Message -----
From: Hossein
To: l...
Sent: Monday, April 04, 2011 9:57 PM
Subject: [lpc2000] LPC2368 reliable operation

Hi all,
I am new to ARM processors and designed a custom board with LPC2368FBD100, I have written a very simple code in keil software which simply turns on two LEDs and turns off two others which I designed in my custom board and intend to use them as indicators (P2.19 -> P2.22) when I download my code to the board - I am using H-Jtag and wiggler LPT cable- I see that my microcontroller oscillator pin is oscillating but no change on the LEDs happens ?!! one strange behavior on these pins is that the voltage level is always -before and after programing -
around 2.25V while other GPIOs which I used for other purposes are 3.3V
-for example push bottons - I tried to change PLL divider and multiplyer values in config wizard of assembly startup file but it doesn't have any effects.
here is the code :

#include /* LPC23xx definitions */

int main(void){
PINSEL3 &= 0XFFFFC03F; //Config LEDs as GPIO pins however their reset value chooses GPIO
//// PINMODE3 &= 0XFFFFC03F; // Enables Pull ups on P1.19 to P1.22 pins
FIO1DIR |= 0X00780000; //Enhanced GPIO Function Registers
while(1){
FIO1SET |= 0X00600000;
FIO1CLR |= 0X00180000;

FIO1SET |= 0X00180000;
FIO1CLR |= 0X00600000;
}
}

can anybody help me?

thanks in advance.
Try the code with just = instead of |=.

On Mon, Apr 4, 2011 at 11:57 AM, Hossein wrote:

> Hi all,
> I am new to ARM processors and designed a custom board with LPC2368FBD100,
> I have written a very simple code in keil software which simply turns on two
> LEDs and turns off two others which I designed in my custom board and intend
> to use them as indicators (P2.19 -> P2.22) when I download my code to the
> board - I am using H-Jtag and wiggler LPT cable- I see that my
> microcontroller oscillator pin is oscillating but no change on the LEDs
> happens ?!! one strange behavior on these pins is that the voltage level is
> always -before and after programing -
> around 2.25V while other GPIOs which I used for other purposes are 3.3V
> -for example push bottons - I tried to change PLL divider and multiplyer
> values in config wizard of assembly startup file but it doesn't have any
> effects.
> here is the code :
>
> #include /* LPC23xx definitions */
>
> int main(void){
> PINSEL3 &= 0XFFFFC03F; //Config LEDs as GPIO pins however their reset value
> chooses GPIO
> //// PINMODE3 &= 0XFFFFC03F; // Enables Pull ups on P1.19 to P1.22 pins
> FIO1DIR |= 0X00780000; //Enhanced GPIO Function Registers
> while(1){
> FIO1SET |= 0X00600000;
> FIO1CLR |= 0X00180000;
>
> FIO1SET |= 0X00180000;
> FIO1CLR |= 0X00600000;
> }
> }
>
> can anybody help me?
>
> thanks in advance.
>
>
>
--- In l..., "Hossein" wrote:
>
> Hi all,
> I am new to ARM processors and designed a custom board with LPC2368FBD100, I have written a very simple code in keil software which simply turns on two LEDs and turns off two others which I designed in my custom board and intend to use them as indicators (P2.19 -> P2.22) when I download my code to the board - I am using H-Jtag and wiggler LPT cable- I see that my microcontroller oscillator pin is oscillating but no change on the LEDs happens ?!! one strange behavior on these pins is that the voltage level is always -before and after programing -
> around 2.25V while other GPIOs which I used for other purposes are 3.3V
> -for example push bottons - I tried to change PLL divider and multiplyer values in config wizard of assembly startup file but it doesn't have any effects.
> here is the code :
>
> #include /* LPC23xx definitions */
> int main(void){
> PINSEL3 &= 0XFFFFC03F; //Config LEDs as GPIO pins however their reset value chooses GPIO
> //// PINMODE3 &= 0XFFFFC03F; // Enables Pull ups on P1.19 to P1.22 pins
> FIO1DIR |= 0X00780000; //Enhanced GPIO Function Registers
> while(1){
> FIO1SET |= 0X00600000;
> FIO1CLR |= 0X00180000;
>
> FIO1SET |= 0X00180000;
> FIO1CLR |= 0X00600000;
> }
> }
>
> can anybody help me?
>
> thanks in advance.
>
I don't know if the code actually works but, if it did, those pins would be toggling about a bazillion times per second. The result would be a voltage somewhere between 0 and Vcc.

I might put some spin loops after each block:

volatile int i; // at the top of main()

for (i = 0; i < 10000000; i++)
;

Of course, your compiler might optimize the loop away if it is don't any level of optimization although with the 'volatile' attribute it shouldn't.

And leave PINSEL alone. The ports are already GPIO.

Richard

--- In l..., "rtstofer" wrote:
>
> --- In l..., "Hossein" wrote:
> >
> > Hi all,
> > I am new to ARM processors and designed a custom board with LPC2368FBD100, I have written a very simple code in keil software which simply turns on two LEDs and turns off two others which I designed in my custom board and intend to use them as indicators (P2.19 -> P2.22) when I download my code to the board - I am using H-Jtag and wiggler LPT cable- I see that my microcontroller oscillator pin is oscillating but no change on the LEDs happens ?!! one strange behavior on these pins is that the voltage level is always -before and after programing -
> > around 2.25V while other GPIOs which I used for other purposes are 3.3V
> > -for example push bottons - I tried to change PLL divider and multiplyer values in config wizard of assembly startup file but it doesn't have any effects.
> > here is the code :
> >
> > #include /* LPC23xx definitions */
> >
> >
> > int main(void){
> > PINSEL3 &= 0XFFFFC03F; //Config LEDs as GPIO pins however their reset value chooses GPIO
> > //// PINMODE3 &= 0XFFFFC03F; // Enables Pull ups on P1.19 to P1.22 pins
> > FIO1DIR |= 0X00780000; //Enhanced GPIO Function Registers
> > while(1){
> > FIO1SET |= 0X00600000;
> > FIO1CLR |= 0X00180000;
> >
> > FIO1SET |= 0X00180000;
> > FIO1CLR |= 0X00600000;
> > }
> > }
> >
> > can anybody help me?
> >
> > thanks in advance.
> >
> I don't know if the code actually works but, if it did, those pins would be toggling about a bazillion times per second. The result would be a voltage somewhere between 0 and Vcc.
>
> I might put some spin loops after each block:
>
> volatile int i; // at the top of main()
>
> for (i = 0; i < 10000000; i++)
> ;
>
> Of course, your compiler might optimize the loop away if it is don't any level of optimization although with the 'volatile' attribute it shouldn't.
>
> And leave PINSEL alone. The ports are already GPIO.
>
> Richard
>

The measurement of 2.25v is about right for the given duty cycle of approximately 50% with pullups enabled. So the code is probably working. You definitely need the delays as Alex and Richard have stated.

Richard good idea to note using "volatile". I've been bitten too many times by compilers optimizing away loops. I still forget to use it.

--- In l..., "Larry Viesse" wrote:
> --- In l..., "rtstofer" wrote:
> >
> >
> >
> > --- In l..., "Hossein" wrote:
> > >
> > > Hi all,
> > > I am new to ARM processors and designed a custom board with LPC2368FBD100, I have written a very simple code in keil software which simply turns on two LEDs and turns off two others which I designed in my custom board and intend to use them as indicators (P2.19 -> P2.22) when I download my code to the board - I am using H-Jtag and wiggler LPT cable- I see that my microcontroller oscillator pin is oscillating but no change on the LEDs happens ?!! one strange behavior on these pins is that the voltage level is always -before and after programing -
> > > around 2.25V while other GPIOs which I used for other purposes are 3.3V
> > > -for example push bottons - I tried to change PLL divider and multiplyer values in config wizard of assembly startup file but it doesn't have any effects.
> > > here is the code :
> > >
> > > #include /* LPC23xx definitions */
> > >
> > >
> > > int main(void){
> > > PINSEL3 &= 0XFFFFC03F; //Config LEDs as GPIO pins however their reset value chooses GPIO
> > > //// PINMODE3 &= 0XFFFFC03F; // Enables Pull ups on P1.19 to P1.22 pins
> > > FIO1DIR |= 0X00780000; //Enhanced GPIO Function Registers
> > > while(1){
> > > FIO1SET |= 0X00600000;
> > > FIO1CLR |= 0X00180000;
> > >
> > > FIO1SET |= 0X00180000;
> > > FIO1CLR |= 0X00600000;
> > > }
> > > }
> > >
> > > can anybody help me?
> > >
> > > thanks in advance.
> > >
> >
> >
> > I don't know if the code actually works but, if it did, those pins would be toggling about a bazillion times per second. The result would be a voltage somewhere between 0 and Vcc.
> >
> > I might put some spin loops after each block:
> >
> > volatile int i; // at the top of main()
> >
> > for (i = 0; i < 10000000; i++)
> > ;
> >
> > Of course, your compiler might optimize the loop away if it is don't any level of optimization although with the 'volatile' attribute it shouldn't.
> >
> > And leave PINSEL alone. The ports are already GPIO.
> >
> > Richard
> > The measurement of 2.25v is about right for the given duty cycle of approximately 50% with pullups enabled. So the code is probably working. You definitely need the delays as Alex and Richard have stated.
>
> Richard good idea to note using "volatile". I've been bitten too many times by compilers optimizing away loops. I still forget to use it.
>

Just noticed that PINMODE3 is commented out. 2.25 volts is still a good estimate at 50% duty cycle at that high a frequency.

Larry

Hi

According to the datasheet of LPc23xx the default operation mode of port 0 and 1 is legacy GPIO,
in order to change these ports to fast GPIO the SCS bit 0 (GPIOM) has to be set to 1 from the default value of 0.

In his code he is not doing that and he is using fast GPIO, will he be able to change the state of the peal pins this way?

The datasheet says:
"Section 37 Other system controls and status flags on page 38). While both of a ports
fast and legacy GPIO registers are controlling the same physical pins, these two port
control branches are mutually exclusive and operate independently. For example,
changing a pins output via a fast register will not be observable via the corresponding
legacy register."

Can the fast GPIO change the pin state without changing GPIOM to 1?

Alex

On 04/05/2011 07:44 AM, Larry Viesse wrote:

> --- In l... ,
> "Larry Viesse" wrote:
> >
> >
> >
> >
> >
> >
> >
> >
> > --- In l... ,
> "rtstofer" wrote:
> > >
> > >
> > >
> > > --- In l... ,
> "Hossein" wrote:
> > > >
> > > > Hi all,
> > > > I am new to ARM processors and designed a custom board with
> LPC2368FBD100, I have written a very simple code in keil software
> which simply turns on two LEDs and turns off two others which I
> designed in my custom board and intend to use them as indicators
> (P2.19 -> P2.22) when I download my code to the board - I am using
> H-Jtag and wiggler LPT cable- I see that my microcontroller oscillator
> pin is oscillating but no change on the LEDs happens ?!! one strange
> behavior on these pins is that the voltage level is always -before and
> after programing -
> > > > around 2.25V while other GPIOs which I used for other purposes
> are 3.3V
> > > > -for example push bottons - I tried to change PLL divider and
> multiplyer values in config wizard of assembly startup file but it
> doesn't have any effects.
> > > > here is the code :
> > > >
> > > > #include /* LPC23xx definitions */
> > > >
> > > >
> > > > int main(void){
> > > > PINSEL3 &= 0XFFFFC03F; //Config LEDs as GPIO pins however their
> reset value chooses GPIO
> > > > //// PINMODE3 &= 0XFFFFC03F; // Enables Pull ups on P1.19 to
> P1.22 pins
> > > > FIO1DIR |= 0X00780000; //Enhanced GPIO Function Registers
> > > > while(1){
> > > > FIO1SET |= 0X00600000;
> > > > FIO1CLR |= 0X00180000;
> > > >
> > > > FIO1SET |= 0X00180000;
> > > > FIO1CLR |= 0X00600000;
> > > > }
> > > > }
> > > >
> > > > can anybody help me?
> > > >
> > > > thanks in advance.
> > > >
> > >
> > >
> > > I don't know if the code actually works but, if it did, those pins
> would be toggling about a bazillion times per second. The result would
> be a voltage somewhere between 0 and Vcc.
> > >
> > > I might put some spin loops after each block:
> > >
> > > volatile int i; // at the top of main()
> > >
> > > for (i = 0; i < 10000000; i++)
> > > ;
> > >
> > > Of course, your compiler might optimize the loop away if it is
> don't any level of optimization although with the 'volatile' attribute
> it shouldn't.
> > >
> > > And leave PINSEL alone. The ports are already GPIO.
> > >
> > > Richard
> > >
> >
> > The measurement of 2.25v is about right for the given duty cycle of
> approximately 50% with pullups enabled. So the code is probably
> working. You definitely need the delays as Alex and Richard have stated.
> >
> > Richard good idea to note using "volatile". I've been bitten too
> many times by compilers optimizing away loops. I still forget to use it.
> > Just noticed that PINMODE3 is commented out. 2.25 volts is still a
> good estimate at 50% duty cycle at that high a frequency.
>
> Larry

Hi all,

Thank you all for your consideration, special thanks to Alex for his useful comment on enabling bit1 of SCS register.
For that level of voltage I should say that pins are in input state after reset and they will remian until you change their mode. When I added SCS|=1; I saw that it was working.

Thank you all and specially Alex.

--- On Tue, 5/4/11, Alex wrote:

From: Alex
Subject: Re: [lpc2000] Re: LPC2368 reliable operation
To: l...
Date: Tuesday, 5 April, 2011, 11:40 AM

Hi

According to the datasheet of LPc23xx the default operation mode of port 0 and 1 is legacy GPIO,
in order to change these ports to fast GPIO the SCS bit 0 (GPIOM) has to be set to 1 from the default value of 0.

In his code he is not doing that and he is using fast GPIO, will he be able to change the state of the peal pins this way?

The datasheet says:
"Section 3–7 “Other system controls and status flags” on page 38). While both of a port’s
fast and legacy GPIO registers are controlling the same physical pins, these two port
control branches are mutually exclusive and operate independently. For example,
changing a pin’s output via a fast register will not be observable via the corresponding
legacy register."

Can the fast GPIO change the pin state without changing GPIOM to 1?

Alex

On 04/05/2011 07:44 AM, Larry Viesse wrote:

> --- In l... ,
> "Larry Viesse" wrote:
> >
> >
> >
> >
> >
> >
> >
> >
> > --- In l... ,
> "rtstofer" wrote:
> > >
> > >
> > >
> > > --- In l... ,
> "Hossein" wrote:
> > > >
> > > > Hi all,
> > > > I am new to ARM processors and designed a custom board with
> LPC2368FBD100, I have written a very simple code in keil software
> which simply turns on two LEDs and turns off two others which I
> designed in my custom board and intend to use them as indicators
> (P2.19 -> P2.22) when I download my code to the board - I am using
> H-Jtag and wiggler LPT cable- I see that my microcontroller oscillator
> pin is oscillating but no change on the LEDs happens ?!! one strange
> behavior on these pins is that the voltage level is always -before and
> after programing -
> > > > around 2.25V while other GPIOs which I used for other purposes
> are 3.3V
> > > > -for example push bottons - I tried to change PLL divider and
> multiplyer values in config wizard of assembly startup file but it
> doesn't have any effects.
> > > > here is the code :
> > > >
> > > > #include /* LPC23xx definitions */
> > > >
> > > >
> > > > int main(void){
> > > > PINSEL3 &= 0XFFFFC03F; //Config LEDs as GPIO pins however their
> reset value chooses GPIO
> > > > //// PINMODE3 &= 0XFFFFC03F; // Enables Pull ups on P1.19 to
> P1.22 pins
> > > > FIO1DIR |= 0X00780000; //Enhanced GPIO Function Registers
> > > > while(1){
> > > > FIO1SET |= 0X00600000;
> > > > FIO1CLR |= 0X00180000;
> > > >
> > > > FIO1SET |= 0X00180000;
> > > > FIO1CLR |= 0X00600000;
> > > > }
> > > > }
> > > >
> > > > can anybody help me?
> > > >
> > > > thanks in advance.
> > > >
> > >
> > >
> > > I don't know if the code actually works but, if it did, those pins
> would be toggling about a bazillion times per second. The result would
> be a voltage somewhere between 0 and Vcc.
> > >
> > > I might put some spin loops after each block:
> > >
> > > volatile int i; // at the top of main()
> > >
> > > for (i = 0; i < 10000000; i++)
> > > ;
> > >
> > > Of course, your compiler might optimize the loop away if it is
> don't any level of optimization although with the 'volatile' attribute
> it shouldn't.
> > >
> > > And leave PINSEL alone. The ports are already GPIO.
> > >
> > > Richard
> > >
> >
> > The measurement of 2.25v is about right for the given duty cycle of
> approximately 50% with pullups enabled. So the code is probably
> working. You definitely need the delays as Alex and Richard have stated.
> >
> > Richard good idea to note using "volatile". I've been bitten too
> many times by compilers optimizing away loops. I still forget to use it.
> > Just noticed that PINMODE3 is commented out. 2.25 volts is still a
> good estimate at 50% duty cycle at that high a frequency.
>
> Larry



Yahoo! Groups Links