Keil Logo

LPC2129 UART Interrupt Enable Problem

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
au ua
Posted
13-Apr-2011 09:33 GMT
Toolset
ARM
New! LPC2129 UART Interrupt Enable Problem

Hi

I am trying to receive bytes from UART0 and UART1 in Interrupt mode. I am enabling UART0 and UART1 Interrupt by the following code:

void initUART1_Intp(void) {

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

U1IER = 0x01; //Enable the RDA interrupt
}

void initUART0_Intp(void) {

VICVectAddr1 = (unsigned long)U0ISR; //Set UART0 ISR Vector Address
VICVectCntl1 = 0x20 |6; //Enable Slot, Set Channel 6
VICIntEnable = 0x40; //Enable Int for UART0

U0IER = 0x01; //Enable the RDA(Rx Data Available) interrupt
}

Is there any problem with this code specially at the last lines (U1IER = 0x01; ) and U0IER =
0x01;

My program is stopping here. Its not going after this statement.

Please help.

Read-Only
Author
Per Westermark
Posted
13-Apr-2011 09:39 GMT
Toolset
ARM
New! RE: LPC2129 UART Interrupt Enable Problem

You forgot to read the instructions on how to post source code. Clearly visible just above the text input box.

Why no code to set any baudrate?

You should do a

dummy = U<n>IIR;


before that last line.

Your program will fail badly when you enable the interrupts, if you don't have a reasonable interrupt handler to process the interrupts from the device. It's just a question if you have a pending interrupt that gets instantly processed or if you may run for a while until the UART has an interrupt that needs servicing.

Read-Only
Author
au ua
Posted
13-Apr-2011 10:15 GMT
Toolset
ARM
New! RE: LPC2129 UART Interrupt Enable Problem

Thanks Per

baud rate code is there and its working. Below is the ISR for UART1. At the stating main() function I am transmitting some strings. What is happening that after sending some characters the progrm is stopping.

void U1ISR(void) __irq                          // Serial Port1 ISR
{
 U1IER = 0x0 ;                                      // Clear Interrupt
 RecData1 = U1RBR ;
 DataRecBit1 = 1 ;
 U1IER  = 0x1 ;                                          // enable Interrupt
 VICVectAddr = 0x0;                              // return from interrupt
 }

I have not written anything for FIFO.

pleae help.

Read-Only
Author
Tamir Michael
Posted
13-Apr-2011 10:21 GMT
Toolset
ARM
New! RE: LPC2129 UART Interrupt Enable Problem
U1IER = 0x0 ;

This does not cleat the interrupt! Reading RBR does. Remove it, but first check the user manual to see what it really does...

Read-Only
Author
Per Westermark
Posted
13-Apr-2011 11:01 GMT
Toolset
ARM
New! RE: LPC2129 UART Interrupt Enable Problem

Don't play with any U<n>IER in the interrupt handler.

You should look at I<n>IIR to check what the interrupt handler is expected to do, so you know if you should read U<n>LSR, U<n>RBR, U<n>MSR or if maybe you should feed a character to U<n>THR (if you have anything to send).

Don't use a single byte and a flag for receiving data. If you can only handle a single character at a time, then it isn't really meaningful with interrupts since the main loop must still poll for that single character before it gets overwritten. Do change to a standard ring buffer where the ISR updates the insert position and the main loop processes characters until the read position reaches the insert position.

Read-Only
Author
Per Westermark
Posted
13-Apr-2011 11:02 GMT
Toolset
ARM
New! RE: LPC2129 UART Interrupt Enable Problem

I<n>IIR should of course be U<n>IIR.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.