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 #367 background imageLoading...
Page #367 background image
Programming Energia (and Arduino)
MSP430 Workshop - Using Energia (Arduino) 8 - 9
How Does ‘Wiring’ Compare?
How does the Wiring language compare to standard C code?
MSP430 C Code vs Wiring Language
Background
Loop
Setup
Code
void setup() {
// Setup pin for output
pinMode (LED_PIN, OUTPUT);
}
void loop() {
digitalWrite (LED_PIN, HIGH); // LED on
delay (1000); // wait 1 second
digitalWrite (LED_PIN, LOW); // LED off
delay (1000);
}
void main() {
// Setup pin for output
P1DIR = 0x40;
P1OUT = 0;
// Disable watchdog timer
WDTCTL = WDTPW | WDTHOLD;
// Setup Master Clock (MCLK)
BCSCTL1 = CALBC1_16MHZ;
DCOCTL = CALDCO_16MHZ;
BCSCTL2 &= ~(DIVS_0);
// Setup ACLK
BCSCTL3 |= LFXT1S_2;
while(1) {
P1OUT = 0x40; // LED on
_delay_cycles(1000); // wait 1 sec
P1OUT = 0; // LED off
_delay_cycles(1000);
}
}
This comparison helps to demonstrate the simplicity of programming with Energia. As stated
before, this can make for very effective rapid prototyping.
Later, during one of the lab exercises, we will examine some of the underpinings of Wiring.
Although the language makes programming easier, the same actual code is required for both
sides of this diagram. In the case of Wiring, this is encapsulated by the language/library. You will
see later on where this is done; armed with this knowledge, you can change the default values
defined by the folks who ported Arduino over to Energia for the TI microcontrollers.

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