2021-11-08
-
zy09 reading assigned. Target done by Wednesday.
-
zy10 reading also assigned. May as well start.
1. UART Serial communication
-
Universal Asynchronous Receiver-Transmitter
The protocol is pretty simple. One. Bit. At. A. Time.
-
Start bit. Mark -> Space transition (usually 1->0)
-
hold low for 1 bit time
-
-
Data bits
-
least-significant bit first!
-
N data bits total (5…?)
-
8-bits is common
-
7-bits is found in oldskool ASCII systems
-
-
-
Parity bit?
-
none
-
even (such that there is an even number of 1’s)
-
odd (… to make an odd number of 1’s)
-
-
Stop bit
-
Second stop bit?
-
optional, rare
-
-
(back to idle)
-
usually back to Mark level (1)
-

ASCII is an encoding, it maps a group of 7-bits (0b0xxx xxxx
)to a symbolic meaning
2. Serial terminal
Supplies:
-
PC with terminal program
-
MSP430 LaunchPad, loaded with msp4th
-
AD2
Watch the protocol in real time.
Open MobaXterm
Session -> Serial

Ensure the MSP430 is attached.
Then, run the session and select a COM Port:

You should see a blank black screen.
Press RST
on your LaunchPad.
You should see
msp4th! >
Forth code:
Paste into Notepad++:
\ word definitions for accessing MSP430 GPIO registers \ builds "ledN" to \ set language to Forth for highlighting \\\\\\\\\\\\\\\\ \ setup some "constant"s \\\\\\\\\\\\\\\\ \ P1OUT register address ( -- &P1OUT ) : P1OUT 0x0200 0x02 + ; \ P9OUT register address ( -- &P9OUT ) : P9OUT 0x0280 0x02 + ; \\\\\\\\\\\\\\\\ \ utility functions (words in Forth) \\\\\\\\\\\\\\\\ \ clear bits at memory address ( mask addr -- ) : bic tuck @ swap ~ & swap ! ; \ set bits at memory address ( mask addr -- ) : bis tuck @ swap | swap ! ; \\\\\\\\\\\\\\\\ \ "application" words \\\\\\\\\\\\\\\\ \ set an LED on/off ( bool -- ) : led1 push0 == if 0x01 P1OUT bic else 0x01 P1OUT bis then ; \ alternate defintion style, doesn't repeat the port/pin info : led1 push0 == 0x01 P1OUT 2 roll if bic else bis then ; \ set led2 to bool ( bool -- ) : led2 push0 == 0x80 P9OUT 2 roll if bic else bis then ; \ example: turn LED1 on then off 1 led1 0 led1
3. msp4th
Download and unzip
msp4th-launchpad.zip
-
Create a new Code Composer Studio project.
-
Replace/paste
main.c
-
Add the other two files to the project.
-
Build and flash
Default configuration uses the built-in LaunchPad UART at 9600 8N1:
-
9600 baud
-
8-bit transfers
-
No parity
-
One stop bit
0 echo
: P1OUT 0x0200 0x02 + ; ( -- &P1OUT )
: P9OUT 0x0280 0x02 + ; ( -- &P9OUT )
: bic tuck @ swap ~ & swap ! ; ( mask addr -- ) \ clear bits at memory address
: bis tuck @ swap | swap ! ; ( mask addr -- ) \ set bits at memory address
//
: led1 push0 == if
0x01 P1OUT bic
else
0x01 P1OUT bis
then ;
: led1 push0 == 0x01 P1OUT 2 roll
if bic
else bis
then ;
: led2 push0 == 0x80 P9OUT 2 roll
if bic
else bis
then ;
1 echo
https://dev.ti.com/tirex/explore/node?devtools=MSP-EXP430FR6989&node=AOpNP3B6FOXx.PNv5ZDeJQIOGqZriLATEST
msp430fr69xx_euscia0_uart_03.c