EmbeddedRelated.com
Forums

LPC2129 UART ISR Problem

Started by lehighuboy October 11, 2006
I'm using the LPC2129 and Keil Tools. The purpose of the code is to
interrupt on the receipt of a single byte of data and assign data to
its value. The interrupt seems to work however data isn't the right
value. Please help, Thanks.


#include /* prototype declarations for I/O functions */
#include /* LPC21xx definitions */

void U1ISR(void) __irq; //Declare UART1 IRQ ISR

int data;

int main (void) {

PINSEL0 = 0x0005800A; // Enable UART1

U1LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
U1DLL = 8; /* 115200 Baud Rate @ 15MHz VPB Clock */
U1LCR = 0x03; /* DLAB = 0 */
U1IER = 0x1; //Enable the RDA interrupt

VICVectAddr0 = (unsigned long)U1ISR; //Set UART1 ISR Vector Address
VICVectCntl0 = 0x20 | 7; //Enable Slot, Set Channel 7
VICIntEnable = 0x80; //Enable Int UART1

blah ... blah ... blah

while (1) {

yada ... yada ... yada

}

}

void U1ISR(void) __irq {

U1IIR |= 0x01; /* Clear Interrupt */

data = U1RBR;

VICVectAddr = 0x0; /* return from interrupt */

}

An Engineer's Guide to the LPC2100 Series

8:40:35 AM, Wednesday, October 11, 2006, lehighuboy wrote:

> I'm using the LPC2129 and Keil Tools. The purpose of the code is to
> interrupt on the receipt of a single byte of data and assign data to
> its value. The interrupt seems to work however data isn't the right
> value.

How do you check it? What are the results?

> int data;

May be

volatile int data;

could help.
WBR, Alex
Thank you for the response.

I tried the volatile tag, however no change occurred.

After some reading I added the following:

U1FCR = 0x07; //Enables and Resets FIFO, 1 byte

Still no change ...

I'm watching the values in the debugger window. "data" should vary from
0x0 to 0xFF, instead there is sporadic change from 0x30 to 0x37.
Thank you for the response.

I tried the volatile tag, however no change occurred.

After some reading I added the following:

U1FCR = 0x07; //Enables and Resets FIFO, 1 byte

Still no change ...

I'm watching the values in the debugger window. "data" should vary
from 0x0 to 0xFF, instead there is sporadic change from 0x30 to 0x37.
--- In l..., Alexey Bishletov wrote:
>
> 8:40:35 AM, Wednesday, October 11, 2006, lehighuboy wrote:
>
> > I'm using the LPC2129 and Keil Tools. The purpose of the code is
to
> > interrupt on the receipt of a single byte of data and assign data
to
> > its value. The interrupt seems to work however data isn't the
right
> > value.
>
> How do you check it? What are the results?
>
> > int data;
>
> May be
>
> volatile int data;
>
> could help.
> WBR, Alex
>
At 04:40 AM 10/11/2006 +0000, lehighuboy wrote:
>I'm using the LPC2129 and Keil Tools. The purpose of the code is to
>interrupt on the receipt of a single byte of data and assign data to
>its value. The interrupt seems to work however data isn't the right
>value. Please help, Thanks.
>
>void U1ISR(void) __irq {
>
>U1IIR |= 0x01; /* Clear Interrupt */

IIR is a ready only register. You keep rewriting the FIFO control register.

An object lesson in the usefulness of const volatile.

Actually, it seems odd that Kiel didn't use const volatile.

Robert

http://www.aeolusdevelopment.com/

From the Divided by a Common Language File (Edited to protect the guilty)
ME - "I'd like to get Price and delivery for connector Part # XXXXX"
Dist./Rep - "$X.XX Lead time 37 days"
ME - "Anything we can do about lead time? 37 days seems a bit high."
Dist./Rep - "that is the lead time given because our stock is live.... we
currently have stock."
Thanks.

How do I clear the interrupt?

--- In l..., Robert Adsett
wrote:
>
> At 04:40 AM 10/11/2006 +0000, lehighuboy wrote:
> >I'm using the LPC2129 and Keil Tools. The purpose of the code is to
> >interrupt on the receipt of a single byte of data and assign data
to
> >its value. The interrupt seems to work however data isn't the right
> >value. Please help, Thanks.
> >
> >void U1ISR(void) __irq {
> >
> >U1IIR |= 0x01; /* Clear Interrupt */
>
> IIR is a ready only register. You keep rewriting the FIFO control
register.
>
> An object lesson in the usefulness of const volatile.
>
> Actually, it seems odd that Kiel didn't use const volatile.
>
> Robert
>
> http://www.aeolusdevelopment.com/
>
At 01:40 AM 10/12/2006 +0000, lehighuboy wrote:
>--- In l..., Robert Adsett
>wrote:
> >
> > At 04:40 AM 10/11/2006 +0000, lehighuboy wrote:
> > >I'm using the LPC2129 and Keil Tools. The purpose of the code is to
> > >interrupt on the receipt of a single byte of data and assign data
>to
> > >its value. The interrupt seems to work however data isn't the right
> > >value. Please help, Thanks.
> > >
> > >void U1ISR(void) __irq {
> > >
> > >U1IIR |= 0x01; /* Clear Interrupt */
> >
> > IIR is a ready only register. You keep rewriting the FIFO control
>register.
> >
> > An object lesson in the usefulness of const volatile.
> >
> > Actually, it seems odd that Kiel didn't use const volatile.
> >
>Thanks.
>
>How do I clear the interrupt?

That depends on the source. There is a table in the user manual that lists
what actions are required for each source.

As a matter of interest, did Keil really leave the const off of the IIR
definition?

Robert

Another sign of the end of civilization, our technical magazines are
getting chatty
From an EETimes product descriptions 2006/08/09
".... systems that can sample gobs of inputs simultaneously"
Now just what is the technical definition for gobs again?
http://www.aeolusdevelopment.com/
Thanks. I deleted my question because I figured there was a section in
the user manual. At any rate with the interrupt clearing resolved, it
still doesn't work ...

--- In l..., Robert Adsett wrote:

> >Thanks.
> >
> >How do I clear the interrupt?
>
> That depends on the source. There is a table in the user manual that
lists
> what actions are required for each source.
>
> As a matter of interest, did Keil really leave the const off of the
IIR
> definition?
>
> Robert
In the Keil header file:

#define U1IIR (*((volatile unsigned char *) 0xE0010008))

--- In l..., "lehighuboy"
wrote:
>
> Thanks. I deleted my question because I figured there was a section
in
> the user manual. At any rate with the interrupt clearing resolved,
it
> still doesn't work ...
>
> --- In l..., Robert Adsett
wrote:
>
> > >Thanks.
> > >
> > >How do I clear the interrupt?
> >
> > That depends on the source. There is a table in the user manual
that
> lists
> > what actions are required for each source.
> >
> > As a matter of interest, did Keil really leave the const off of
the
> IIR
> > definition?
> >
> > Robert
>
At 02:29 AM 10/12/2006 +0000, lehighuboy wrote:
>Thanks. I deleted my question because I figured there was a section in
>the user manual. At any rate with the interrupt clearing resolved, it
>still doesn't work ...

I didn't take a close look at everything. IIR just rather popped out at me.

Take a look at the examples in the files section. There are also examples
in the newlib-lpc library.

Robert

" 'Freedom' has no meaning of itself. There are always restrictions,
be they legal, genetic, or physical. If you don't believe me, try to chew
a radio signal. " -- Kelvin Throop, III
http://www.aeolusdevelopment.com/