akshada
Member level 3
I m trying to configure my UART irq but for some reason it is not working.I've tested my UART without IRQ and was working fine.
thanks in advance.......
Code:
void UARTInit(unsigned long baudrate)
{
volatile char dummy;
unsigned long Fdiv;
PCONP |= (1<<4);
PINSEL0 |= 0x00050000;
U1LCR = 0x83; /* DLAB =1, STOP =1, NO PARIY, WORD LENGTH = 8 */
Fdiv = ( 15000000UL / 16 ) / baudrate ; /* baud rate */
U1DLM = Fdiv / 256;
U1DLL = Fdiv % 256;
U1LCR = 0x03; /* DLAB = 0 */
U1FCR = 0x07; /* Enable and reset TX and RX FIFO. */
VICVectAddr7 = (unsigned long)UART1Handler; /* set interrupt vector 2 to UART0_IRQHandler interrupt function*/
VICVectCntl7 = (0x20 | 7); /* enable slot & use it for UART0 Interrupt */
VICIntEnable |= (unsigned long)(1<<7); /* Enable UART0 Interrupt */
dummy = U1IIR; /* Read IrqID - Required to Get Interrupts Started */
U0IER = IER_RBR | IER_THRE | IER_RLS; /* Enable UART0 interrupt */
}
__irq void UART1Handler (void)
{
unsigned char IIRValue, LSRValue;
IIRValue = U1IIR;
IIRValue >>= 1; /* skip pending bit in IIR */
IIRValue &= 0x07; /* check bit 1~3, interrupt identification */
if ( IIRValue == IIR_THRE ) /* THRE, transmit holding register empty */
{
/* THRE interrupt */
LSRValue = U1LSR; /* Check status in the LSR to see if
valid data in U0THR or not */
if ( LSRValue & LSR_THRE ) // if(transmitter empty)
{
UART1TxEmpty = 1; //empty
}
else
{
UART1TxEmpty = 0; //char available
}
}
VICVectAddr = 0; /* Acknowledge Interrupt */
}
void UARTSend( unsigned char *BufferPtr)
{
while (*BufferPtr)
{
while ( !(UART1TxEmpty & 0x01) ); /*THRE status, contain valid data */
U1THR = *BufferPtr;
UART1TxEmpty = 0; /*not empty in the THR until it shifts out */
BufferPtr++;
}
}