Sign in

Not a member? | Forgot your Password?


Search lpc2000



Search tips

Subscribe to lpc2000



Free PDF Downloads

Advanced Linux Programming

What Every Programmer Should Know About Memory

Introduction to Embedded Systems

C++ Tutorial

Embedded Systems - Theory and Design Methodology

Discussion Groups

See Also

ElectronicsDSPFPGA

Find us on Facebook





Discussion Groups | LPC2000 | Problem with UART0 interrupts on LPC2364 and LPC2387

Discussion group dedicated to the Philips LPC2000 family of ARM MCUs

Problem with UART0 interrupts on LPC2364 and LPC2387 - niksaorlic - Jul 12 11:12:45 2008

I am trying to add UART communication to my project and am having some
problems. I am using UART interrupts. Here is the UART initialization
code:

PINSEL0 = 0x00000050;
U0LCR = 0x83;
Fdiv = ( Fpclk / 16 ) / baudrate ;
U0DLM = Fdiv / 256;
U0DLL = Fdiv % 256;
U0LCR = 0x03;
U0FCR = 0x07;
U0IER = 3;
install_irq( UART0_INT, (void *)uart0_irq, HIGHEST_PRIORITY );

The (simplifed) interrupt handler routine is as follows:

void uart0_irq (void) __irq {
char dummy;
while (((IIR = U0IIR) & 0x01) == 0) {
switch (IIR & 0x0E) {
case 0x06:
dummy = U0LSR;
break;
case 0x04:
case 0x0C:
LastReceivedChar = U0RBR;
break;
case 0x02:
break;
}
}
VICVectAddr = 0; /* Acknowledge Interrupt */
}

By simplifying my program to simply echo all characters received, I
observe the following:

- after I reprogram the LPC (using FlashMagic), and start the program
for the first time, the echo program behaves OK
- after I hard-reset the LPC, my main while(1) loop runs OK until I
send a first character over UART from PC to LPC; then the LPC stop
running (the UART0 interrupt routine is not even entered)

I thought this had to do with spurious interrupts, but I found a
document saying that spurious interrupts problem has been solved on
LPC23xx series, and the VicDefVectAddr register is not even available
on LPC23xx MCUs.

What do I need to do to have proper interrupts on UART0?

Thanks,
Niksa

_____________________________
 Free pdf download: An Engineer's Guide to the LPC2100 Series.


Re: Problem with UART0 interrupts on LPC2364 and LPC2387 - 42Bastian - Jul 12 12:48:27 2008

> PINSEL0 = 0x00000050;

Id do this:
PINSEL0 &= ~(0x000000f0);
PINSEL0 |= 0x000000050;

>
> The (simplifed) interrupt handler routine is as follows:
>
> void uart0_irq (void) __irq {
> char dummy;
> while (((IIR = U0IIR) & 0x01) == 0) {
> switch (IIR & 0x0E) {
> case 0x06:
> dummy = U0LSR;
> break;
> case 0x04:
> case 0x0C:
> LastReceivedChar = U0RBR;
> break;

Here my code loops:
while ( (UnLSR (CNF_DRUID_UNIT) & UART_LSR_RDR) ){
c = (__u8)UnRBR (CNF_DRUID_UNIT);
rxisr (c);
}

Unless the noted, I see no difference.

> - after I reprogram the LPC (using FlashMagic), and start the program
> for the first time, the echo program behaves OK
> - after I hard-reset the LPC, my main while(1) loop runs OK until I
> send a first character over UART from PC to LPC; then the LPC stop
> running (the UART0 interrupt routine is not even entered)

What happens if you let it run from reset with debugger ?

--
42Bastian

_____________________________
 Free pdf download: An Engineer's Guide to the LPC2100 Series.


Re: Problem with UART0 interrupts on LPC2364 and LPC2387 - niksaorlic - Jul 14 7:34:39 2008

I have noticed an additional behavior. When I create a timer and
enable it, (the timer uses interrupt), the timer "freezes" the LPC,
before the interrupt handler function was entered. If I create a timer
and do not start (enable) it, the LPC is running fine.

It seems that I am having some sort of problem with interrupts
handling. (btw - I am using PLL but not MAM, if this helps) Can anyone
help?

Best regards,
Niksa
--- In l..., "niksaorlic" wrote:
>
> I am trying to add UART communication to my project and am having some
> problems. I am using UART interrupts. Here is the UART initialization
> code:
>
> PINSEL0 = 0x00000050;
> U0LCR = 0x83;
> Fdiv = ( Fpclk / 16 ) / baudrate ;
> U0DLM = Fdiv / 256;
> U0DLL = Fdiv % 256;
> U0LCR = 0x03;
> U0FCR = 0x07;
> U0IER = 3;
> install_irq( UART0_INT, (void *)uart0_irq, HIGHEST_PRIORITY );
>
> The (simplifed) interrupt handler routine is as follows:
>
> void uart0_irq (void) __irq {
> char dummy;
> while (((IIR = U0IIR) & 0x01) == 0) {
> switch (IIR & 0x0E) {
> case 0x06:
> dummy = U0LSR;
> break;
> case 0x04:
> case 0x0C:
> LastReceivedChar = U0RBR;
> break;
> case 0x02:
> break;
> }
> }
> VICVectAddr = 0; /* Acknowledge Interrupt */
> }
>
> By simplifying my program to simply echo all characters received, I
> observe the following:
>
> - after I reprogram the LPC (using FlashMagic), and start the program
> for the first time, the echo program behaves OK
> - after I hard-reset the LPC, my main while(1) loop runs OK until I
> send a first character over UART from PC to LPC; then the LPC stop
> running (the UART0 interrupt routine is not even entered)
>
> I thought this had to do with spurious interrupts, but I found a
> document saying that spurious interrupts problem has been solved on
> LPC23xx series, and the VicDefVectAddr register is not even available
> on LPC23xx MCUs.
>
> What do I need to do to have proper interrupts on UART0?
>
> Thanks,
> Niksa
>


_____________________________
 Free pdf download: An Engineer's Guide to the LPC2100 Series.


Re: Problem with UART0 interrupts on LPC2364 and LPC2387 - niksaorlic - Jul 14 8:50:24 2008

Problem solved - I am embarrassed :)

I had the define _DEBUG_RAM instead of _DEBUG_FLASH defined.

Thanks for your help.

Regards,
Niksa

--- In l..., "niksaorlic" wrote:
>
> I have noticed an additional behavior. When I create a timer and
> enable it, (the timer uses interrupt), the timer "freezes" the LPC,
> before the interrupt handler function was entered. If I create a timer
> and do not start (enable) it, the LPC is running fine.
>
> It seems that I am having some sort of problem with interrupts
> handling. (btw - I am using PLL but not MAM, if this helps) Can anyone
> help?
>
> Best regards,
> Niksa
> --- In l..., "niksaorlic" wrote:
> >
> > I am trying to add UART communication to my project and am having some
> > problems. I am using UART interrupts. Here is the UART initialization
> > code:
> >
> > PINSEL0 = 0x00000050;
> > U0LCR = 0x83;
> > Fdiv = ( Fpclk / 16 ) / baudrate ;
> > U0DLM = Fdiv / 256;
> > U0DLL = Fdiv % 256;
> > U0LCR = 0x03;
> > U0FCR = 0x07;
> > U0IER = 3;
> > install_irq( UART0_INT, (void *)uart0_irq, HIGHEST_PRIORITY );
> >
> > The (simplifed) interrupt handler routine is as follows:
> >
> > void uart0_irq (void) __irq {
> > char dummy;
> > while (((IIR = U0IIR) & 0x01) == 0) {
> > switch (IIR & 0x0E) {
> > case 0x06:
> > dummy = U0LSR;
> > break;
> > case 0x04:
> > case 0x0C:
> > LastReceivedChar = U0RBR;
> > break;
> > case 0x02:
> > break;
> > }
> > }
> > VICVectAddr = 0; /* Acknowledge Interrupt */
> > }
> >
> > By simplifying my program to simply echo all characters received, I
> > observe the following:
> >
> > - after I reprogram the LPC (using FlashMagic), and start the program
> > for the first time, the echo program behaves OK
> > - after I hard-reset the LPC, my main while(1) loop runs OK until I
> > send a first character over UART from PC to LPC; then the LPC stop
> > running (the UART0 interrupt routine is not even entered)
> >
> > I thought this had to do with spurious interrupts, but I found a
> > document saying that spurious interrupts problem has been solved on
> > LPC23xx series, and the VicDefVectAddr register is not even available
> > on LPC23xx MCUs.
> >
> > What do I need to do to have proper interrupts on UART0?
> >
> > Thanks,
> > Niksa
>

_____________________________
 Free pdf download: An Engineer's Guide to the LPC2100 Series.