Forums

need help, LPC2138 /01 UART0

Started by nelson Zhu April 30, 2010
I have a system using LPC2138 /01, UART0 is connected to PC comm port, 9600-8-2-N. UART0 is interrupt driven. We have only one wire for the RS232 line, so we have some circuitry to combine the RX and TX line. I first use JTAG to program our loader into the chip, and the loader talks to PC fine. But when I start to load application program using the loader, it sometimes hangs my program before it finishes. The application program is in intel hex format, about 370kB. I used another RS232 to listen to that line, and found out that sometimes there are some junk come up on that line besides the file I send, I guess that is the reason why it crashed my program,(or it could be the result). And the problem varies with different PC, some fails more frequent others not so frequent. I have tried many things, but just could not get rid of it, it now comes once out of 10 times.

Anyone has any idea?

Thanks,

--Nelson

An Engineer's Guide to the LPC2100 Series

nelson Zhu wrote:
> I have a system using LPC2138 /01, UART0 is connected to PC comm
> port, 9600-8-2-N. UART0 is interrupt driven. We have only one wire
> for the RS232 line, so we have some circuitry to combine the RX and
> TX line.

What kind of circuit? Do you AND the logic level signals or what?

> I first use JTAG to program our loader into the chip, and the loader
> talks to PC fine. But when I start to load application program using
> the loader, it sometimes hangs my program before it finishes.

What kind of protocol do you use? Does the loader acknoledge the
commands coming from PC? How do you make sure that they are not talking
over each other?

> The application program is in intel hex format, about 370kB. I used
> another RS232 to listen to that line, and found out that sometimes
> there are some junk come up on that line besides the file I send,

When? At the start or the end of the transfer or randomly? Can you check
with a scope where the junk originates?

> I guess that is the reason why it crashed my program,(or it could be
> the result).

Which program? The one in PC or the loader?

> And the problem varies with different PC, some fails more frequent
> others not so frequent. I have tried many things, but just could not
> get rid of it, it now comes once out of 10 times.

That points to timing dependent problems...

--

Timo

Hi Nelson,

Can you give more details on how the Tx and Rx lines are combined?
Is communication between your loader and the PC bi-directional? Does, for instance, the loader periodically acknowledge blocks of data sent by the PC?

I'm thinking that perhaps the problem lies in the way communication is being switched from transmit to receive. Is it possible there is a period of time when receive lines aren't being driven and are floating? If so, they might occasionally be detected to be in a state they shouldn't be. Perhaps that causes a false start bit which throws everything else off.

Good luck,
Norman

________________________________
From: nelson Zhu
To: l...
Sent: Fri, April 30, 2010 6:39:29 AM
Subject: [lpc2000] need help, LPC2138 /01 UART0

I have a system using LPC2138 /01, UART0 is connected to PC comm port, 9600-8-2-N. UART0 is interrupt driven. We have only one wire for the RS232 line, so we have some circuitry to combine the RX and TX line. I first use JTAG to program our loader into the chip, and the loader talks to PC fine. But when I start to load application program using the loader, it sometimes hangs my program before it finishes. The application program is in intel hex format, about 370kB. I used another RS232 to listen to that line, and found out that sometimes there are some junk come up on that line besides the file I send, I guess that is the reason why it crashed my program,(or it could be the result). And the problem varies with different PC, some fails more frequent others not so frequent. I have tried many things, but just could not get rid of it, it now comes once out of 10 times.

Anyone has any idea?

Thanks,

--Nelson
Yes, it is an AND logic.

During downloading, it is one directional from PC to uC, no ACK, so I should not see any UART0 TX activity, but it is hard to distinguish because there is only one line.

The junk comes out randomly. It was my loader that crashed.

And one thing I forgot to mention is that the code wad developed in 2007, and intensive tests were done even at very high temp(even out of spec), I never notice this problem, even now, my engineering board still works fine. The problem started with our first production batched in late 2009. I think there are a few manufacturing revision difference between my development chip and the production one, which is Rev E.

--Nelson

----- Original Message ----
From: Timo
To: l...
Sent: Fri, April 30, 2010 9:14:04 AM
Subject: Re: [lpc2000] need help, LPC2138 /01 UART0

nelson Zhu wrote:
> I have a system using LPC2138 /01, UART0 is connected to PC comm
> port, 9600-8-2-N. UART0 is interrupt driven. We have only one wire
> for the RS232 line, so we have some circuitry to combine the RX and
> TX line.

What kind of circuit? Do you AND the logic level signals or what?

> I first use JTAG to program our loader into the chip, and the loader
> talks to PC fine. But when I start to load application program using
> the loader, it sometimes hangs my program before it finishes.

What kind of protocol do you use? Does the loader acknoledge the
commands coming from PC? How do you make sure that they are not talking
over each other?

> The application program is in intel hex format, about 370kB. I used
> another RS232 to listen to that line, and found out that sometimes
> there are some junk come up on that line besides the file I send,

When? At the start or the end of the transfer or randomly? Can you check
with a scope where the junk originates?

> I guess that is the reason why it crashed my program,(or it could be
> the result).

Which program? The one in PC or the loader?

> And the problem varies with different PC, some fails more frequent
> others not so frequent. I have tried many things, but just could not
> get rid of it, it now comes once out of 10 times.

That points to timing dependent problems...

--

Timo

Please see my reply to Timo.

I have changed many different things, here are some more of my test results,

1. configure some of the TRACE pins to GPIO seems to make some difference, improved a little.
2. Adding about 8 seconds delay before start loading seems to help a lot.
3. The shorter the loading time, the easier it will pass, the longest was about 370k, takes around 7 min, shortest is about 4 min.

Thanks,

--Nelson

________________________________
From: Norman Felder
To: l...
Sent: Fri, April 30, 2010 9:34:35 AM
Subject: Re: [lpc2000] need help, LPC2138 /01 UART0

Hi Nelson,

Can you give more details on how the Tx and Rx lines are combined?
Is communication between your loader and the PC bi-directional? Does, for instance, the loader periodically acknowledge blocks of data sent by the PC?

I'm thinking that perhaps the problem lies in the way communication is being switched from transmit to receive. Is it possible there is a period of time when receive lines aren't being driven and are floating? If so, they might occasionally be detected to be in a state they shouldn't be. Perhaps that causes a false start bit which throws everything else off.

Good luck,
Norman

________________________________
From: nelson Zhu
To: lpc2000@yahoogroups .com
Sent: Fri, April 30, 2010 6:39:29 AM
Subject: [lpc2000] need help, LPC2138 /01 UART0

I have a system using LPC2138 /01, UART0 is connected to PC comm port, 9600-8-2-N. UART0 is interrupt driven. We have only one wire for the RS232 line, so we have some circuitry to combine the RX and TX line. I first use JTAG to program our loader into the chip, and the loader talks to PC fine. But when I start to load application program using the loader, it sometimes hangs my program before it finishes. The application program is in intel hex format, about 370kB. I used another RS232 to listen to that line, and found out that sometimes there are some junk come up on that line besides the file I send, I guess that is the reason why it crashed my program,(or it could be the result). And the problem varies with different PC, some fails more frequent others not so frequent. I have tried many things, but just could not get rid of it, it now comes once out of 10 times.

Anyone has any idea?

Thanks,

--Nelson
nelson Zhu wrote:
> During downloading, it is one directional from PC to uC, no ACK, so I
> should not see any UART0 TX activity, but it is hard to distinguish
> because there is only one line.

If you have a scope and access into the board signals, then it would be
easy to measure if there is any activity on TX line of the uC.

> The junk comes out randomly. It was my loader that crashed.

Does the junk and crash happen always at the same time?

> And one thing I forgot to mention is that the code wad developed in
> 2007, and intensive tests were done even at very high temp(even out of
> spec), I never notice this problem, even now, my engineering board still
> works fine. The problem started with our first production batched in
> late 2009. I think there are a few manufacturing revision difference
> between my development chip and the production one, which is Rev E.

That might be explained by something being on the verge - memory timings
or something like that. Maybe you should try to slow down them a bit.

--

Timo

Hi Nelson,

At this point I would be looking for some non-obvious problems that may or may not be directly associated with the serial communication circuit. For instance:
a) Quickly check the oscillator with a scope and verify that the frequency is correct and the waveform shape is clean
b) put a scope on the power rail supplying the processor and verify that it is clean and the voltage is well inside the nominal limits.
c) make sure the ground connection in the serial cable establishes a ground all the way from the PC to ground on the circuit board

Taking a close look at any differences between your engineering prototype, which works correctly, and the production boards, which don't, might be profitable. For instance, maybe someone substituted a 5V only AND gate on the production board in place of a 3.3V part on your engineering board - something dumb like that.

Let us know if you find anything,
Brian

________________________________
From: nelson Zhu
To: l...
Sent: Fri, April 30, 2010 9:19:06 AM
Subject: Re: [lpc2000] need help, LPC2138 /01 UART0

Please see my reply to Timo.

I have changed many different things, here are some more of my test results,

1. configure some of the TRACE pins to GPIO seems to make some difference, improved a little.
2. Adding about 8 seconds delay before start loading seems to help a lot.
3. The shorter the loading time, the easier it will pass, the longest was about 370k, takes around 7 min, shortest is about 4 min.

Thanks,

--Nelson

________________________________
From: Norman Felder
To: lpc2000@yahoogroups .com
Sent: Fri, April 30, 2010 9:34:35 AM
Subject: Re: [lpc2000] need help, LPC2138 /01 UART0

Hi Nelson,

Can you give more details on how the Tx and Rx lines are combined?
Is communication between your loader and the PC bi-directional? Does, for instance, the loader periodically acknowledge blocks of data sent by the PC?

I'm thinking that perhaps the problem lies in the way communication is being switched from transmit to receive. Is it possible there is a period of time when receive lines aren't being driven and are floating? If so, they might occasionally be detected to be in a state they shouldn't be. Perhaps that causes a false start bit which throws everything else off.

Good luck,
Norman

________________________________
From: nelson Zhu
To: lpc2000@yahoogroups .com
Sent: Fri, April 30, 2010 6:39:29 AM
Subject: [lpc2000] need help, LPC2138 /01 UART0

I have a system using LPC2138 /01, UART0 is connected to PC comm port, 9600-8-2-N. UART0 is interrupt driven. We have only one wire for the RS232 line, so we have some circuitry to combine the RX and TX line. I first use JTAG to program our loader into the chip, and the loader talks to PC fine. But when I start to load application program using the loader, it sometimes hangs my program before it finishes. The application program is in intel hex format, about 370kB. I used another RS232 to listen to that line, and found out that sometimes there are some junk come up on that line besides the file I send, I guess that is the reason why it crashed my program,(or it could be the result). And the problem varies with different PC, some fails more frequent others not so frequent. I have tried many things, but just could not get rid of it, it now comes once out of 10 times.

Anyone has any idea?

Thanks,

--Nelson
Hi Timo,

These are production board, I am not allowed to do soldering on the board. So I can only work with few test points or clip on some leaded pins. I am going to get a board for engineering soon.

The junk and crash comes at different time, and sometimes it does not crash and started running my application code, seems like the PC was messed up..

And talking about memory, I forgot to mention that I was using IAP copy ram to flash command, and I met a weird problem there which I fixed but still don't know why it did it. That problem was that I write 256 byte from RAM to flash at a time, but for some reason, it remembers the last block in the RAM, if I don't power cycle it, and load a different program, it will always write in the previous last block into the current last block. I fixed it by fill the RAM up with FF after the last block write. And I toggled a test IO pin to measure the flash writing, it seems like it takes more than 2 ms to write, and my UART0 interrupt comes at about 1ms. I am not sure if that could cause any problem.

Regarding the TXD pin, I tried to configure it as input IO during download, and it still failed.

Regards,

--Nelson

----- Original Message ----
From: Timo
To: l...
Sent: Fri, April 30, 2010 10:43:23 AM
Subject: Re: [lpc2000] need help, LPC2138 /01 UART0

nelson Zhu wrote:
> During downloading, it is one directional from PC to uC, no ACK, so I
> should not see any UART0 TX activity, but it is hard to distinguish
> because there is only one line.

If you have a scope and access into the board signals, then it would be
easy to measure if there is any activity on TX line of the uC.

> The junk comes out randomly. It was my loader that crashed.

Does the junk and crash happen always at the same time?

> And one thing I forgot to mention is that the code wad developed in
> 2007, and intensive tests were done even at very high temp(even out of
> spec), I never notice this problem, even now, my engineering board still
> works fine. The problem started with our first production batched in
> late 2009. I think there are a few manufacturing revision difference
> between my development chip and the production one, which is Rev E.

That might be explained by something being on the verge - memory timings
or something like that. Maybe you should try to slow down them a bit.

--

Timo

--- In l..., nelson Zhu wrote:
And I toggled a test IO pin to measure the flash writing, it seems like it takes more than 2 ms to write, and my UART0 interrupt comes at about 1ms. I am not sure if that could cause any problem.
>
> --Nelson

If your interrupt code is in flash, you can not have interrupts enabled while using IAP.

Search the User Manual for "Interrupts during IAP" It is in section 21.4.10 of the LPC2148 UM.

Richard

Richard,

I did disable the interrupt when I called the IAP command. I think it would have failed constantly if I hadn't done that.

--Nelson

________________________________
From: rtstofer
To: l...
Sent: Fri, April 30, 2010 2:19:22 PM
Subject: [lpc2000] Re: need help, LPC2138 /01 UART0

--- In lpc2000@yahoogroups .com, nelson Zhu wrote:
And I toggled a test IO pin to measure the flash writing, it seems like it takes more than 2 ms to write, and my UART0 interrupt comes at about 1ms. I am not sure if that could cause any problem.
>
> --Nelson

If your interrupt code is in flash, you can not have interrupts enabled while using IAP.

Search the User Manual for "Interrupts during IAP" It is in section 21.4.10 of the LPC2148 UM.

Richard