MSP432 serial printf

While the MSP432, does seem to be an kickin' rad microcontroller, I've noticed a distinct lack of resources online to do the most basic microcontrolley stuff.

So this is a quick bit of code to get a serial/UART connection up and going from the MSP432 to your computer over the USB connection. Perfect for any debugging that you might want to do, or communication with other serial devices (for example the exciting ESP8266 which I'll cover in a later blog post).

The MSP432-printf library, which is largely from 43oh member OPossum (printf for the MSP430), lets you print to any serial module using standard printf syntax. For example: printf(EUSCI_A0_MODULE, "String one: %d", 1). The code for the library can be found on my GitHub.

An example of using this printf library with the MSP432 is shown below.

The code configures EUSCI_A0_MODULE to be used and then prints to it. EUSCI_A0_MODULE is, by default the application UART that you can connect to over USB from your PC. One thing to note is to make sure that EUSCI_A_UART_LSB_FIRST is set in the UART config, rather than EUSCI_A_UART_MSB_FIRST. According to wikipedia, MSB first serial communication is rarely used and it's much more common to use little endian or LSB first communications. If you use a program like PuTTY, it's likely that it'll interpret the serial stream as little endian.

To connect to the MSP432, I use PuTTY. On my PC, the MSP432 is on COM1. It's possible to configure and use serial modules other than EUSCI_A0_MODULE but this may involve some datasheet investigation!



comments powered by Disqus