Software Examples
On the F5529 LaunchPad, 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 and are independent from the 40-pin BoosterPack
header.
shows some constants in bcUart.h that define the library's behavior.
Table 7. Backchannel Library: Constants to Configure
Constant
Description
UCA1_OS
UCA1_BR0
Set the baudrate. Must be adjusted if SMCLK speed or baudrate are configured to anything
UCA1_BR1
other than 8 MHz and 28.8 kbps, respectively. See bcUart.h for instructions.
UCA1_BRS
UCA1_BRF
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.
When this number of bytes have been received into the receive buffer, the
BC_RX_WAKE_THRESH
bcUartRxThresholdReached flag is set to TRUE, and the main application is awakened from
any LPM it might be in.
shows the library's function calls.
Table 8. Backchannel Library: Functions
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.
Copy any bytes received into the library's UART receive buffer into
buf
uint16_t
bcUartReceiveBytesInBuffer
(uint8_t* buf)
and return the number of bytes copied.
The library includes a definition of the USCI_A1 ISR, which copies
USCI_A1 Interrupt Vector
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's ISR.
3.6.5
Code Description: Initialization
First, the device must be initialized. Although called from main(), much of this initialization is defined within
hal.c and hal.h. Most of the examples in the USB API v4.0 and later include this hardware abstraction
layer (HAL) file to assist in running on multiple USB-equipped boards available from TI. Clocks, power,
and port settings can be hardware-specific and, thus, are handled by the HAL. This demo follows that
convention.
3.6.5.1
Stopping the Watchdog
The MSP430 contains a watchdog timer that is enabled by default. After a reset, an MSP430 application
has approximately 32 ms to either reconfigure the watchdog or put it on hold. Otherwise, the watchdog
resets the MSP430 device.
Watchdogs are an important part of writing robust production-level code, but if you are only experimenting
with the MCU, it is not helpful and can be obstructive. For this reason, the first line of code on many bench
applications is to simply disable the watchdog by setting the WDTHOLD bit.
3.6.5.2
Configuring V
CORE
Next, main() sets the PMMCOREV register field to 2. PMMCOREV controls the V
CORE
voltage, which is the
voltage at which the MCU's core circuitry operates. V
CORE
is generated from a low-dropout (LDO) regulator
inside the MCU's Power Management Module (PMM). Higher CPU operating speeds require higher V
CORE
levels, and higher V
CORE
levels result in higher quiescent current on the LDO. For this reason, V
CORE
is
programmable.
44
MSP-EXP430F5529LP LaunchPad™ Development Kit User's Guide
SLAU533B – September 2013 – Revised June 2014
Copyright © 2013–2014, Texas Instruments Incorporated