Reply by niksaorlic July 14, 20082008-07-14
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
>

An Engineer's Guide to the LPC2100 Series

Reply by niksaorlic July 14, 20082008-07-14
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
>

Reply by 42Bastian July 12, 20082008-07-12
> 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
Reply by niksaorlic July 12, 20082008-07-12
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