understanding CF5234's UART TX Interrupt

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

understanding CF5234's UART TX Interrupt

1,800件の閲覧回数
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
ラベル(1)
0 件の賞賛
返信
2 返答(返信)

471件の閲覧回数
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 件の賞賛
返信

471件の閲覧回数
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 件の賞賛
返信