Other Parts Discussed in Thread: MSP430FR5969
I am having difficulty writing interrupt driven serial transmit for the FR5969 UART.
The problem begins with the documentation because the user guide is not at all clear on exactly how the interrupts work. The trick, as always, is what to do when no more data is available and what to do to start up the UART.
One possibility is that servicing the TXIFG interrupt clears that interrupt so if no more data is available you do nothing. Then when new data appears you must stuff the first byte into TXBUF before the interrupt routine takes over. That doesn't seem to apply here.
The other is that servicing the TXIFG interrupt does not clear the interrupt so that when no data is available TXIE must be cleared. Then when new data appears it must be enabled again. This is what I assumed was the case and is how I wrote my code.
All starts off well enough as an initial string of data is sent as expected. The problem is that once the program settles into its loop where it looks for serial input data and then echos it, the transmit interrupt never occurs.
Which is very odd because the transmit routine is identical for both cases. I am at a loss to explain why the initial string is sent but subsequent character at a time data is not.
The TI code examples are of no help here because while they show use of serial interrupts, they focus on the receive interrupt. Searching for other examples didn't turn up much. What I did find was a FreeRTOS demo that uses exactly the same method that is failing for me.
Excerpt of the code showing the transmit routines:
txint: pushm.w #3,r15 ; save registers used (r13-r15) mov #txqueue,r15 ; get char from queue call #dequeue tst r15 jn txempty ; queue empty? mov.b r15,&UCA0TXBUF ; no, transmit char jmp txidone txempty: bic.b #1,&P1OUT bic #UCTXIE,&UCA0IE txidone: popm.w #3,r15 ; restore registers reti tx: pushm.w #3,r14 mov r15,r12 ; copy char to transmit txloop: mov r12,r15 mov #txqueue,r14 call #enqueue tst r15 jnz txloop ; repeat until char accepted jmp txdone txdone: bis.b #1,&P1OUT bis #UCTXIE,&UCA0IE popm.w #3,r14 ret