EasyManuals Logo

Texas Instruments MSP430 Student Guide

Texas Instruments MSP430
398 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #384 background imageLoading...
Page #384 background image
Lab 8
8 - 26 Gettings Started with the MSP430 - Using Energia (Arduino)
Lab 8c – Serial Communication (and Debugging)
This lab uses the serial port (UART) to send data back and forth to the PC from the Launchpad.
In and of itself, this is a useful and common thing we do in embedded processing. It’s the most
common way to talk with other hardware. Beyond that, this is also the most common debugging
method in Arduino programming. Think of this as the “printf” for the embedded world of
microcontrollers.
1. Open the DigitalReadSerial example.
Once again, we find there’s a (very) simple example to get us started.
File Examples 1.Basics DigitalReadSerial
2. Save sketch as myDigitalReadSerial.
3. Examine the code.
This is a very simple program, but that’s good since it’s very easy to see what
Energia/Arduino needs to get the serial port working.
/* DigitalReadSerial
Reads a digital input on pin 2, prints the result to the
serial monitor (This example code is in the public domain) */
void setup() {
Serial.begin(9600); // msp430g2231 must use 4800
pinMode(PUSH2, INPUT_PULLUP);
}
void loop() {
int sensorValue = digitalRead(PUSH2);
Serial.println(sensorValue);
}
As you can see, serial communication is very simple. Only one function call is needed to
setup the serial port: Serial.begin(). Then you can start writing to it, as we see here in the
loop() function.
Note: Why are we limited to 9600 baud (roughly, 9600 bits per second)?
The G2553 Launchpad’s onboard emulation (USB to serial bridge) is limited to 9600
baud. It is not a hardware limitation of the MSP430 device. Please refer to the wiki for
more info: https://github.com/energia/Energia/wiki/Serial-Communication.
If you’re using other Launchpads (such as the ‘F5529 Launchpad), your serial port can
transmit at much higher rates.

Table of Contents

Other manuals for Texas Instruments MSP430

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments MSP430 and is the answer not in the manual?

Texas Instruments MSP430 Specifications

General IconGeneral
BrandTexas Instruments
ModelMSP430
CategoryMicrocontrollers
LanguageEnglish

Related product manuals