Hello,
I'm using LPC 3250 Developer's Kit. I want to study the UART 5 with the TX interrupt enabled. Here is the piece of c code compiled using RVDS and debugged using DSTREAM.
The program is transmitting the characters to hyper terminal but I was expecting the character 'I' to be transmitted when it enters the IRQ ISR. But it didn't.
Need your assistance to generate interrupt in IRQ mode for UART 5 Transmission.
Thank You S GR
#include "lpc32xx_uart.h" #include "lpc32xx_timer.h" #include "lpc32xx_chip.h" /**************************************************************************************** *Function :send_data *Inputs :string *Output :none *Purpose :To print the string on serial port ****************************************************************************************/ void send_data(unsigned char ch) { UartReg.dll_fifo=ch; while(!(UartReg.lsr & 0x20)); } /**************************************************************************************** *Function :send_data *Inputs :string *Output :none *Purpose :To print the string on serial port ****************************************************************************************/ void send_string(volatile unsigned char *str) { while(*str != '\0') { send_data(*str); str++; } } /**************************************************************************************** *Function :receive_data *Inputs :string *Output :none *Purpose :To print the string on serial port ****************************************************************************************/ unsigned char receive_data(void) { unsigned char ch; while(!(UartReg.lsr & 0x01)); ch=UartReg.dll_fifo; return(ch); } /**************************************************************************************** *Function :uart5_MICInit *Inputs : *Output : *Purpose : ****************************************************************************************/ void uart5_MICInit(void) { UartReg.dlm_ier = UART_IER_THRE; // Enable UART Tx Interrupt MIC_APR |= (1<<9); // Activation Polarity (Active High for UART 5) MIC_ATR &= ~(1<<9); // Activation Type (Level 0) MIC_ITR &= ~(1<<9); // Interrupt Type (IRQ = 0) MIC_ER |= (1<<9); // Enable register for UART 5 } int main(void) { uart5_MICInit(); send_string((unsigned char *)"UART5 LPC3250 \n\r"); while(1) { ch = receive_data(); send_data(ch); } return 1; } __irq void IRQ_Handler(void) { send_data('I'); // for uart5 return; }
NB: UART was not re-Initialised !
You say that like it's a good thing. It really isn't!
But tons of I is being printed. Do you have any explanation for that ?
Yes, the interrupt is being executed, it clears the cause of the interrupt, but once the loaded 'I' is issued another interrupt will be generated.
Your copy of the vector should not be required. Examine the LPC32x0.S file (specifically RAM_INTVEC).
It's good to see that you're making progress, but I recommend that you stop and think. Then your progress might be more dramatic.
Drew Kneel
Thanks for the support and the explanations.
Thx
S GR