SLAU533D September 2013 – April 2017
This example includes a simple library for the backchannel UART, which can be copied into any project to use the backchannel. It can also be modified as needed. Copy bcUart.c and bcUart.h into the target project, and include the bcUart.h file from any files that access it.
The library is preconfigured to use SMCLK as the clock source, and for the speed of SMCLK to be 8 MHz. The baudrate is preconfigured for 28.8 kbps with no hardware flow control.
SMCLK is generally a good choice for the backchannel UART in a given application, but the clock speeds may change. Instructions for this are located in bcUart.h.
On the F5529 LaunchPad development kit, the backchannel UART is implemented with the USCI_A1 module. The RTS and CTS flow control signals are implemented on the P6.7 and P1.7 I/O pins, respectively. All of these locations are hardwired on the F5529 LaunchPad development kit and are independent from the 40-pin BoosterPack plug-in module header.
Table 7 shows some constants in bcUart.h that define the library behavior.
Constant | Description |
---|---|
UCA1_OS
UCA1_BR0 UCA1_BR1 UCA1_BRS UCA1_BRF |
Set the baudrate. Must be adjusted if SMCLK speed or baudrate are configured to anything other than 8 MHz and 28.8 kbps, respectively. See bcUart.h for instructions. |
BC_USE_HW_FLOW_CONTROL | If hardware flow control is desired, un-comment this #define |
BC_RXBUF_SIZE | Set the size of the buffer that receives data over the backchannel UART. |
BC_RX_WAKE_THRESH | When this number of bytes have been received into the receive buffer, the bcUartRxThresholdReached flag is set to TRUE, and the main application is awakened from any LPM it might be in. |
Table 8 shows the library function calls.
Function | Description |
---|---|
void bcUartInit(void) | Call once during program initialization |
void bcUartSend(uint8_t * buf, uint8_t len) | Send len bytes stored at buf over the UART. |
uint16_t bcUartReceiveBytesInBuffer(uint8_t* buf) | Copy any bytes received into the library UART receive buffer into buf and return the number of bytes copied. |
USCI_A1 Interrupt Vector | The library includes a definition of the USCI_A1 ISR, which copies incoming UART bytes into a receive buffer. |
If the application uses the USCI_A1 ISR for another purpose in addition to the backchannel, it is necessary to merge that operation with the backchannel library ISR.