Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] LPC2106, able to write flash, but code not working

Status
Not open for further replies.

jayanthyk192

Full Member level 3
Full Member level 3
Joined
Sep 17, 2010
Messages
179
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Visit site
Activity points
2,580
Hi,

I have a self made LPC2106 board. I'm able to write the flash, but a simple LED blinking code doesn't work. I'm using keil startup code, 11.0592MHz external crystal. Here's the simple code:

Code:
#include <LPC210x.H>                       /* LPC21xx definitions */

void delay (void) 
{                        /* wait function */
  int  d;

  for (d = 0; d < 10000; d++);           /* only to delay for LED flashes */
}

int main (void) 
{

  IODIR = (1<<19);                     
 
  while (1)  
  {                         
   IOSET=(1<<19);
   delay();	delay();delay();delay();delay();
   IOCLR=(1<<19);           
   delay();	delay();delay();delay();delay();
  }
  
}

I compile and write the flash using FLASH magic. I connected an LED on P0.19. It doesnt blink. I even tried to reverse the LED supply, i.e. from pin -> ground to pin->3.3V, meaning it's floating. I'm setting P0.14 to 0V while flashing and pulled to 3.3V during code running. But still nothing is happening. So any suggestions?

Thank you.
 

Driving an LED directly without a current limiting resistor is typically not advisable.

However, I believe the LPC2106, as well as the entire LPC21xx family of devices, is only capable of sinking or sourcing 4mA per GPIO pin.

Attempting to drive most standard leaded LEDs with such a low current may not be successful.

A more viable technique would be to drive the LED utilizing a transistor with a proper current limiting resistor in series.



I would also suggest studying both the datasheet and user manual of the device, not knowing the basic limits of the device can result in a damaged microcontroller.


BigDog
 

Driving an LED directly without a current limiting resistor is typically not advisable.

However, I believe the LPC2106, as well as the entire LPC21xx family of devices, is only capable of sinking or sourcing 4mA per GPIO pin.

Attempting to drive most standard leaded LEDs with such a low current may not be successful.

A more viable technique would be to drive the LED utilizing a transistor with a proper current limiting resistor in series.


Www
I would also suggest studying both the datasheet and user manual of the device, not knowing the basic limits of the device can result in a damaged microcontroller.


BigDog
I'm sorry I forgot to mention it. There is a 220ohms resistor in between the led and supply pin.
 

I'm sorry I forgot to mention it. There is a 220ohms resistor in between the led and supply pin.

Well that is good to know, you had me worried.

Try driving the LED with a transistor or find a low current LED 2mA/5mA and if you are still having problems post them.



BigDog
 

Well that is good to know, you had me worried.

Try drive the LED with a transistor or find a low current LED 2mA/5mA and if you are still having problems post them.



BigDog
I removed the led and used a multimeter to test the level and it remained in 0v.
 

Do you have the development board in front of you?

If so, lets take a step back.

Rewrite your code to simply raise the output pin high and use your multimeter to verify it is indeed at 3.3v.

Meanwhile I will examine your code, I already see a possible issue.

By the way, what compiler are you utilizing?


BigDog
 

I already tried it, nothing happened 0v. I'm using kell with their startup file, unmodified.
 


Well that is not good news. Did you set the pin high within a while(1) loop?

Is this a commercial development board or a board of your own design?

BigDog

I set the high outside the loop and removed anything inside it. The meter still reads .3V.

I made the board myself. Do you need details?
 

Yes, can you post a schematic?

BigDog

I dont have the schematic. I looked at the datasheet and wired the MC. So, I'll just give the connections.


RST-> 4.7K ->3.3V
-> switch ->Gnd

X1 -> ->38pF ->Gnd
Crystal(11.0592Mhz)
X2 -> ->38pF ->Gnd

VSS 7, 19, 31,43 Gnd

VDD1.8 -> 1.8V (measured)

VDD3 17, 40 ->3.3V (measured)

TX,RX to serail port.

P0.14 -> 4.7K -> 3.3V
-> switch ->gnd (for bootloader mode)

P0.19 -> output

All other connections are open.
 

Any decouple/bypass capacitors (100nF), from all Vdd to Vss?

Vdd 1.8v is connect to which pin, it is omitted in your reply?

Also the capacitors on your crystal should be more in the 15-22pF range, although that should not prevent oscillation.

I've attached a LPC2106 development board schematic, you might want to examine.

I typically use a JTAG programmer, so my experience Flash Magic is limited.

After flashing the device are you resetting it to allow it to begin execution?


BigDog
 

Attachments

  • IAR_LPC2106_Rev2.pdf
    603.9 KB · Views: 96
Last edited:

Sorry for the delay.

Any decouple/bypass capacitors (100nF), from all Vdd to Vss?
No, I was running it on a battery and so i didn't add them. Should I?

Vdd 1.8v is connect to which pin, it is omitted in your reply?
to pin5

Also the capacitors on your crystal should be more in the 15-22pF range, although that should prevent oscillation.
In that case the FLASH Magic should give me an error with autobaud. It doesn't. And the datasheet said 38pF so i used it.

After flashing the device are you resetting it to allow it to begin execution?
Yes I send the P0.14 to VCC and reset.

EDIT: I found a new thing. When I held the meter with the probes touching the lines, i got some .5V, But then i held the probe with my finger touching it and I got 3.3V. Then I set it to zero and still got 3.3V with finger touching and .5V without it. So, is the problem with ground or any other?
 
Last edited:

No, I was running it on a battery and so i didn't add them. Should I?

Yes.


In that case the FLASH Magic should give me an error with autobaud. It doesn't. And the datasheet said 38pF so i used it.

I mistakenly omitted the word "not," as in "that should not prevent oscillation."

The only other suggestion I have at the moment is try another GPIO pin, the pin you are currently using is part of the JTAG port, although I believe it should default as GPIO on reset.


I'll review everything in the morning and post any additional ideas.


BigDog

- - - Updated - - -

Just to be sure pull both DBGSEL pin 27 low and RTCK pin 26 high with a 10K resistor, they both supposedly have internal pull up/down resistors however many of the development board schematics provide external resistors.



BigDog

- - - Updated - - -

EDIT: I found a new thing. When I held the meter with the probes touching the lines, i got some .5V, But then i held the probe with my finger touching it and I got 3.3V. Then I set it to zero and still got 3.3V with finger touching and .5V without it. So, is the problem with ground or any other?

As I'm troubleshooting hardware remotely, I would find it difficult to make a definitive statement concerning that situation.

Double check all your connections with your multimeter and make sure you have good Vdd and Vss supplies.

Perhaps you should configure an transistor to drive the LED and see if you get a high level on the pin.

BigDog
 
Last edited:

Ok, I'll do it.thank you for all the help. Please let me know if you come across any solution.
 

I already tried it, nothing happened 0v. I'm using kell with their startup file, unmodified.

I assume you mean just the specific pin, can you try to set high all the pins of the mcu so we can see if it actually responds?

Code:
IODIR = 0xffffffff;
IOPIN = 0xffffffff;


Do you have a legacy LPC2016 (LPC2016/00) or the enhanced version LPC2106/01?
If you have the /01 device and the outputs are set to fast IO mode (although they shouldn't by default) they don't change by the IODIR/IOSET/IOCLR/IOPIN but FIODIR/FIOSET/FIOCLR/FIOPIN, changind the legacy GPIO registers will not affect the output pins.

The registers that set fast IO are missing from the header so you should add

Code:
/* FAST General Purpose Input/Output (FGPIO) */
#define SCS          (*((volatile unsigned long *) 0xE01FC1A0))
#define FIOPIN          (*((volatile unsigned long *) 0x3FFFC014))
#define FIOSET          (*((volatile unsigned long *) 0x3FFFC018))
#define FIODIR          (*((volatile unsigned long *)  0x3FFFC000))
#define FIOCLR          (*((volatile unsigned long *) 0x3FFFC01C))

Code:
SCS= 0; // set to slow IO just to be sure
IODIR = 0xffffffff;
IOPIN = 0xffffffff;

For fast IO you can use
Code:
SCS = 1; // set to fast IO
FIODIR = 0xffffffff;
FIOPIN = 0xffffffff;
 

Code:
IODIR = 0xffffffff;
IOPIN = 0xffffffff;

I tried that but again nothing. As I saw in the datasheet, IOPIN reads the pin value or the port bit register according to IODIR. So, I tried IOSET but again nothing.

Do you have a legacy LPC2016 (LPC2016/00) or the enhanced version LPC2106/01?

The one I have is LPC2106B, not the one you mentioned.
 

I tried that but again nothing. As I saw in the datasheet, IOPIN reads the pin value or the port bit register according to IODIR. So, I tried IOSET but again nothing.

The one I have is LPC2106B, not the one you mentioned.


IOPIN gives direct access to the IO register, you can either read it to get the state of a pin or write it to set the state of a pin.

So no pin is responsive to your program, are you sure that you do actually write the program to the device , do you get a confirmation?

- - - Updated - - -

By LPC2016 (LPC2016/00) I meant LPC2106 (LPC2106/00) of course but it seems you do not have a /01 device

- - - Updated - - -

Can you please zip the project folder of uvision, I wonder if the cause of the problem is there (maybe a wrong memory space )
 

Is your crystal working?
I think so, because the bootloader is running.

IOPIN gives direct access to the IO register, you can either read it to get the state of a pin or write it to set the state of a pin.

So no pin is responsive to your program, are you sure that you do actually write the program to the device , do you get a confirmation?
In FLash Magic it says "finished" after a series of write and verify cycles

Can you please zip the project folder of uvision, I wonder if the cause of the problem is there (maybe a wrong memory space )

Here it is : View attachment arm.rar
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top