Hi,
So I've noticed a strange problem implementing my uart interrupt handler. According to the documentation, the UCA0TXIFG is set when the uart is ready for more data, and cleared when data is written to it. What I'm seeing with the debugger is the flag being cleared automatically as soon as it goes to the interrupt handler and is set as soon as data is written to it -- the opposite behavior that is supposed to happen.
In the code below, when it hits the TX_NOT_OK() line, the UCA0TXIFG bit is cleared, and as soon as the I populate the UCA0TXBUF, the bit is re-set (it might be transmitting the data and setting it before the debugger gets to it) - but the main problem I have is that the UCA0TXIFG bit is cleared by the handler even when no data is written to the uart. In my code, if I don't have any data to transmit, I disable the interrupt handler and return -- the UCA0TXIFG bit is thus never set and when I re-enable the interrupt vector, it never calls it.
Any thoughts? Is there a hardware bug?
Thnx,
Reza
#pragma vector=USCI_A0_VECTOR __interrupt void uart0_interrupt(void){ uint16_t i; switch(__even_in_range(UCA0IV,4)) { // No Interrupt case 0: break; // RXIFG ------------- case 2: i = UCA0RXBUF; rb_push(&rb_uartIN, i); break; // TXIFG -------------- case 4: if (TX_NOT_OK()) { //Check if RTS is HIGH DISSABLE_UART0_TX(); //dissables the interrupt for TX return; } i = rb_pop(&buff); if (i & NO_DATA) { DISSABLE_UART0_TX(); return; } UCA0TXBUF = (uint8_t)i; break; default: break; } }