Forums

UART0 LPC2148 - RBR Interrupt

Started by sb_gustavo September 27, 2007
Hi friends,

I need to use the LPC2148 UART0 data RX interruption (RBR interrupt
or RDA), however the interruption is not happening.
The software below doesn't work.
I'm using the compiler of the IAR Workbench.

Please, help me!

#include

#define green 0x00400000

int data;

__irq void uart0 (void);

int main(void)
{
int cont, delay;

/* Clock - APB e PLL */

VPBDIV = 0x00;

/* IOs */

IO0DIR = 0x826FFD5D;
IO1DIR = 0x010E0000;
PINSEL0 = 0x00001505;
PINSEL1 = 0x15004000;
PINSEL2 = 0x00000000;

/* UART0 - 9600bps */

U0LCR = 0x83;
U0DLL = 0x27;
U0DLM = 0x00;
U0LCR = 0x03;
U0FCR = 0x07;

U0IER = 0x01; // enable RDA interrupt

/* Interrupt*/

VICProtection = 0; // disable protection
VICIntEnClear = 0xFFFFFFFF; // disable all interruptions

VICIntSelect &= 0xFFFFFFBF; // IRQ
VICVectAddr0 = (unsigned)&uart0;
VICVectCntl0 = 0x20 | 6;
VICIntEnable = 0x00000040; // enable

while(1)
{
blah....
blah....
blah....
}
}

__irq void uart0 ()
{
data = U0RBR; // receives data
IO0SET = green;
U0THR = data; // send to computer *It doesn't happen*

VICVectAddr = 0x0;
}

An Engineer's Guide to the LPC2100 Series

sb_gustavo wrote:
> Hi friends,
>
> I need to use the LPC2148 UART0 data RX interruption (RBR interrupt
> or RDA), however the interruption is not happening.
> The software below doesn't work.
> I'm using the compiler of the IAR Workbench.
>
> Please, help me!
I don't see you enabling interrupts for starters.

somewhere before your while(1) place:
__enable_interrupt();

It may require
#include for IAR4
#include for IAR5
I have a IAR UART example here targeting LPC2148:
http://www.indyelectronics.com/code.lpc214x.peripherals.iar.zip
Joel
--- In l..., "Joel Winarske" wrote:
>
> sb_gustavo wrote:
> > Hi friends,
> >
> > I need to use the LPC2148 UART0 data RX interruption (RBR
interrupt
> > or RDA), however the interruption is not happening.
> > The software below doesn't work.
> > I'm using the compiler of the IAR Workbench.
> >
> > Please, help me!
> I don't see you enabling interrupts for starters.
>
> somewhere before your while(1) place:
> __enable_interrupt();
>
> It may require
> #include for IAR4
> #include for IAR5
> I have a IAR UART example here targeting LPC2148:
> http://www.indyelectronics.com/code.lpc214x.peripherals.iar.zip
> Joel
>

Joel,

I made the alteration what you recommended.
The interruption is happening, but it isn't executing the function
uart0.
What can be the problem?
> Joel,
>
> I made the alteration what you recommended.
> The interruption is happening, but it isn't executing the function
> uart0.
> What can be the problem?

The flow goes as follows:
You register your interrupt handler to the interrupt controller. You want
to define your interrupt handler with
__irq __arm void XXXXX (void)

The __irq will surpress prolog/epilog ASM added to the ISR function.
All interrupt handler code must be ARM, hence the __arm.

In your startup code the interrupt vector for an IRQ can point to a couple
of places. Direct to interrupt controller, or an ISR dispatcher.

As long as your code is registered with interrupt controller and the
actual interrupt vector is pointing to the right place, your interrupt
code will fire.

So it sounds like the path from interrupt vector is not making it to your
ISR code - uart0.

Review the example....
Joel
Hi Joel,

I am also working on the same my application is that when I type some characters on the hyperterminal I should hit the receive interrupt ISR. I am working on MCB2130 board with LPC2138 controller and it would be great if you could provide me an example code for UART0 receive mode that genrates the interrupt.

I am running short of time hence it woul be great if anyone can send me the code.

Thx in advance,
shilu
----- Original Message -----
From: Joel Winarske
To: l...
Sent: Fri, 5 Oct 2007 02:40:28 +0530 (IST)
Subject: Re: [lpc2000] Re: UART0 LPC2148 - RBR Interrupt
> Joel,
>
> I made the alteration what you recommended.
> The interruption is happening, but it isn't executing the function
> uart0.
> What can be the problem?

The flow goes as follows:
You register your interrupt handler to the interrupt controller. You want
to define your interrupt handler with
__irq __arm void XXXXX (void)

The __irq will surpress prolog/epilog ASM added to the ISR function.
All interrupt handler code must be ARM, hence the __arm.

In your startup code the interrupt vector for an IRQ can point to a couple
of places. Direct to interrupt controller, or an ISR dispatcher.

As long as your code is registered with interrupt controller and the
actual interrupt vector is pointing to the right place, your interrupt
code will fire.

So it sounds like the path from interrupt vector is not making it to your
ISR code - uart0.

Review the example....
Joel

--
My life has changed. What about yours?
Log on to the new Indiatimes Mail and Live out of the Inbox!
Running short of time == class project due?

And your FIRST mistake is using Hyperdoo-doo, er, I mean, Hyperterm.
How they ever convinced Microsoft to ship that piece of junk with
Windows is beyond me. My theory is they have some photographs of Bill
Gates with a goat.

--jc

--- In l..., Shilpa Shilpa wrote:
>
> Hi Joel,
>
> I am also working on the same my application is that when I type
some characters on the hyperterminal I should hit the receive
interrupt ISR. I am working on MCB2130 board with LPC2138 controller
and it would be great if you could provide me an example code for
UART0 receive mode that genrates the interrupt.
>
> I am running short of time hence it woul be great if anyone can send
me the code.
>
> Thx in advance,
> shilu
> ----- Original Message -----
> From: Joel Winarske
> To: l...
> Sent: Fri, 5 Oct 2007 02:40:28 +0530 (IST)
> Subject: Re: [lpc2000] Re: UART0 LPC2148 - RBR Interrupt
> > Joel,
> >
> > I made the alteration what you recommended.
> > The interruption is happening, but it isn't executing the function
> > uart0.
> > What can be the problem?
>
> The flow goes as follows:
> You register your interrupt handler to the interrupt controller.
You want
> to define your interrupt handler with
> __irq __arm void XXXXX (void)
>
> The __irq will surpress prolog/epilog ASM added to the ISR function.
> All interrupt handler code must be ARM, hence the __arm.
>
> In your startup code the interrupt vector for an IRQ can point to a
couple
> of places. Direct to interrupt controller, or an ISR dispatcher.
>
> As long as your code is registered with interrupt controller and the
> actual interrupt vector is pointing to the right place, your interrupt
> code will fire.
>
> So it sounds like the path from interrupt vector is not making it to
your
> ISR code - uart0.
>
> Review the example....
> Joel
> --
> My life has changed. What about yours?
> Log on to the new Indiatimes Mail and Live out of the Inbox!
>
--- In l..., "jcwren" wrote:
>
> Running short of time == class project due?
>
> And your FIRST mistake is using Hyperdoo-doo, er, I mean, Hyperterm.
> How they ever convinced Microsoft to ship that piece of junk with
> Windows is beyond me. My theory is they have some photographs of Bill
> Gates with a goat.

I heard it was Billy with a Jackass, but who knows?

On a more serious note, HT is er... 'not very good' and can lead you
to believe that there are problems with your UART driver when there
are none.

It is not an OS problem - STT software using ReadFile or ReadFileEx
returns the correct data.

That, and the miserable hoops you have to go through to get out of the
app - 'Are you sure?' , 'Do you want to save the connection' etc. Who
has time for that crap?

Is it so difficult for a serial terminal app to just start up with the
config. it was last shut down with? Rhetorical, because it just isn't.

Rgds,
Martin 'Windows developer saddled with an LPC/ARM project' James.
Hi All,

I have an example code for UART0 in interrupt mode in LPC2138 processor and I am making use of the MCB2130 evaluation board.The code is such that it hits the ISR only when you type something on the hyperterminal but the problem here is the characters I type doesnot match with the one i.e. getting displayed on the terminal i.e. if I am typing as A B C D it receives as A # & etc... which clearly means that from the PC side I am unable to receive the proper characters.Hence I request you to tell me to what might be the reason behind the wrong receiving of the characters.

Thanks,
fasgfdgfs
----- Original Message -----
From: Shilpa Shilpa
To: l...
Sent: Fri, 5 Oct 2007 10:50:50 +0530 (IST)
Subject: Re: [lpc2000] Re: UART0 LPC2148 - RBR Interrupt

Hi Joel,

I am also working on the same my application is that when I type some characters on the hyperterminal I should hit the receive interrupt ISR. I am working on MCB2130 board with LPC2138 controller and it would be great if you could provide me an example code for UART0 receive mode that genrates the interrupt.

I am running short of time hence it woul be great if anyone can send me the code.

Thx in advance,
shilu
----- Original Message -----
From: Joel Winarske
To: l...
Sent: Fri, 5 Oct 2007 02:40:28 +0530 (IST)
Subject: Re: [lpc2000] Re: UART0 LPC2148 - RBR Interrupt
> Joel,
>
> I made the alteration what you recommended.
> The interruption is happening, but it isn't executing the function
> uart0.
> What can be the problem?

The flow goes as follows:
You register your interrupt handler to the interrupt controller. You want
to define your interrupt handler with
__irq __arm void XXXXX (void)

The __irq will surpress prolog/epilog ASM added to the ISR function.
All interrupt handler code must be ARM, hence the __arm.

In your startup code the interrupt vector for an IRQ can point to a couple
of places. Direct to interrupt controller, or an ISR dispatcher.

As long as your code is registered with interrupt controller and the
actual interrupt vector is pointing to the right place, your interrupt
code will fire.

So it sounds like the path from interrupt vector is not making it to your
ISR code - uart0.

Review the example....
Joel

--
My life has changed. What about yours?
Log on to the new Indiatimes Mail and Live out of the Inbox!
If the terminal program on the PC has baud rate or other configuration
that does not match the microcontroller code, you will see A # & etc.
Check the baud rate, data bits, stop bits, flow control settings and
compare with the microcontroller configuration.

Shilpa Shilpa wrote:
> the characters I type doesnot match with the one i.e. getting displayed
> on the terminal i.e. if I am typing as A B C D it receives as A # & etc...
Doug Sutherland
Proficio Research
http://www.proficio.ca/
Hi,

Strange issue that I see is nothing gets written into the memory address provided to the UART1 THR regsiter in LPC2138.I have an example code that initialises the UART1 LCR,baud rate to 9600 and
again disables the respective bits in LCR to access the U1THR regsiter.I am just writing a value of 65 in this regsiter.Though this gets displayed as "A" on the hyperterminal which is correct it indicates a value of 0x0 when i see the memory address issued to this regsiter and also in the peripherals regsiter window.
I am not sure to what step I am missing that is not allowing me to write into this register.I request you all to provdie me help regarding this.

Thanks,

----- Original Message -----
From: Shilpa Shilpa
To: l...
Sent: Tue, 9 Oct 2007 08:54:47 +0530 (IST)
Subject: Re: [lpc2000] Re: UART0 LPC2148 - RBR Interrupt

Hi All,

I have an example code for UART0 in interrupt mode in LPC2138 processor and I am making use of the MCB2130 evaluation board.The code is such that it hits the ISR only when you type something on the hyperterminal but the problem here is the characters I type doesnot match with the one i.e. getting displayed on the terminal i.e. if I am typing as A B C D it receives as A # & etc... which clearly means that from the PC side I am unable to receive the proper characters.Hence I request you to tell me to what might be the reason behind the wrong receiving of the characters.

Thanks,
fasgfdgfs
----- Original Message -----
From: Shilpa Shilpa
To: l...
Sent: Fri, 5 Oct 2007 10:50:50 +0530 (IST)
Subject: Re: [lpc2000] Re: UART0 LPC2148 - RBR Interrupt

Hi Joel,

I am also working on the same my application is that when I type some characters on the hyperterminal I should hit the receive interrupt ISR. I am working on MCB2130 board with LPC2138 controller and it would be great if you could provide me an example code for UART0 receive mode that genrates the interrupt.

I am running short of time hence it woul be great if anyone can send me the code.

Thx in advance,
shilu
----- Original Message -----
From: Joel Winarske
To: l...
Sent: Fri, 5 Oct 2007 02:40:28 +0530 (IST)
Subject: Re: [lpc2000] Re: UART0 LPC2148 - RBR Interrupt
> Joel,
>
> I made the alteration what you recommended.
> The interruption is happening, but it isn't executing the function
> uart0.
> What can be the problem?

The flow goes as follows:
You register your interrupt handler to the interrupt controller. You want
to define your interrupt handler with
__irq __arm void XXXXX (void)

The __irq will surpress prolog/epilog ASM added to the ISR function.
All interrupt handler code must be ARM, hence the __arm.

In your startup code the interrupt vector for an IRQ can point to a couple
of places. Direct to interrupt controller, or an ISR dispatcher.

As long as your code is registered with interrupt controller and the
actual interrupt vector is pointing to the right place, your interrupt
code will fire.

So it sounds like the path from interrupt vector is not making it to your
ISR code - uart0.

Review the example....
Joel

--
My life has changed. What about yours?
Log on to the new Indiatimes Mail and Live out of the Inbox!
--
My life has changed. What about yours?
Log on to the new Indiatimes Mail and Live out of the Inbox!