Hi,
Another "getting back into MSP430s" question...
I''ve been using the backchannel UART with putty to message to-and-fro with an MSP430FR5969 Launchpad... all working fine... I'm using CCS 6.2 with a fully-licensed TI compiler & the latest driverlib/MSPware & C++ (not C).
The UART example that comes with driverlib has the EUSCI_A_UART_receiveData call in the USCI_A0_VECTOR ISR under USCI_UART_UCRXIFG UCA0IV case statement.
All well & good, except the ULP Advisor complains about it (understandably) as really, best practice should be to set a flag in the ISR and then to act on that in the main loop outside of LPM... the driverlib example is simplistic and not an exemplar.
I'm concerned about not dropping characters if I move the RX read outside of the ISR.... I'm thinking that for both USCI_UART_UCRXIFG & USCI_UART_UCTXIFG I should set an appropriate volatile flag and cancel LPM, then in the main loop, if there is RX data, read a byte, then check tx ready, and if OK send a byte, then process other stuff and if nothing left to do, go back into LPM3.x
It would seem sensible to always read data first (before trying to write) as that would help stop dropping characters. "other stuff" would seeing if the read buffer now contained a sensible string, e.g. a GPS NMEA sentence, and then processing it...
However, I'm still nervous about data loss when processing something that takes a while in the main code - I might lose input characters...
Is this scheme flawed, or is there a decent, interrupt-driven, TX/RX example of best practice?
Thanks