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.
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.
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.
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...
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.
I<n>IIR should of course be U<n>IIR.