understanding CF5234's UART TX Interrupt

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

understanding CF5234's UART TX Interrupt

1,656 Views
sirlenzelot
Contributor II
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
Labels (1)
0 Kudos
2 Replies

327 Views
Arev
Contributor III
Hello,

First, check that UART Interruptions are enabled in your UART Initialisation Code:
 
MCF_UART_UIMR0 = ( 0 | MCF_UART_UISR_TXRDY             // Enable Interruption TxRDY
                                         | MCF_UART_UISR_RXRDY_FU );  // EnableInterruption RxRDY
Second, to transmit chars, Enable the UART TX, this will automatically set USR0[TxEMP,TxRDY] and cause an interrupt.
 
MCF_UART_UCR0 = MCF_UART_UCR_TX_ENABLED;
I Hope this helps..

Bye
0 Kudos

327 Views
sirlenzelot
Contributor II
Hello Arev,
thanks for your fast answer.
For enabling the transmission of data i did not switch UART TX. I switched the interrupt on and off using UART.UIMR.TXRDY. Maybe that was the mistake.
Thanks again.
 
best regards (vy73)
Sir Lenzelot
0 Kudos