sirlenzelot

understanding CF5234's UART TX Interrupt

Discussion created by sirlenzelot on Mar 19, 2007
Latest reply on Mar 20, 2007 by sirlenzelot
Hello,
 
UART TRX works fine at the moment using polling, but I'd like to use interrupts.
RX interrupt is no problem but I am not sure what I have to do for TX. Maybe someone can give a hint?
 
status quo:
 
1) set interrupt vector
2) init UART
3) fill UART_TX_q
4) activate TX interrupt (UART.UISR.TXRDY = 1)
 
Now my ISR is called and the TX_q will be send.
When finished, I switch off TX interrupt (UART.UISR.TXRDY = 0)
 
I'd like to do an internal loopback test to ensure everything is okay before granting access to UART.
For testing, I activate TX interrupt. My ISR is called and in the ISR, one Byte is put to UART.UTB and TX interrupt is switched off. Due to loopback, UART.USR.RXRDY is set and the interrupt should be triggered again, but nothing happens. UART.USR.RXRDY is set but the ISR is not called. It seems, my programm does not recognize the RX interrupt.
 
 
 
Code:
char BUTX = 64;
char BURX = 255;
interrupt void UART0_isr(void){// RX if ((UART0.USR.R & 0x1) == 0x1) {  BURX = UART0.UTRB.B.BUF; } else// TX if ((UART0.UISR.R & 0x1) == 0x1) {  UART0.UTRB.B.BUF = BUTX;  UART0.UISR.B.TXRDY = 0; }}
void main()
{
 setISR();  // set interrupt and isr
 initUART();  // set local loopback mode
 UART.UISR.TXRDY = 1; // enable UART TX interrupt
// Now ISR is called
while (BUTX != BURX) // Wait for RX interrupt
{
 // Do nothing
}
}

 
please note that i have replaced the q with a single char (BUTX / BURX) for testing.
Thanks for your suggestions.
 
best regards (vy 73)
 
Sir Lenzelot

Outcomes