O'Reilly logo

Microcontroller Programming and Interfacing Texas Instruments MSP430 by Daniel J. Pack, Steven F. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

363
APPENDIX A
Programming
A.1 OVERVIEW
This Appendix was adapted from a chapter entitled “Programming” from “Arduino Processing for
Everyone [Barrett]!”
To the novice, programming a microcontroller may appear mysterious, complicated, over-
whelming, and difficult. When faced with a new task, one often does not know where to start. The
goal of this Appendix is to provide a tutorial on how to begin programming. We will use a top-down
design approach. We begin with the “big picture” of the appendix, followed by an overview of the
major pieces of a program. We then discuss the basics of the C programming language. Only the
most fundamental concepts will be covered. Throughout the appendix, we provide examples and
also provide references to a number of excellent references.
A.2 THE BIG PICTURE
Most microcontrollers are programmed with some variant of the C programming language. The C
programming language provides a nice balance between the programmer’s control of the microcon-
troller hardware and time efficiency in programming writing.
As you can see in Figure A.1, the compiler software is hosted on a computer separate from
the MSP430 development board. The job of the compiler is to transform the program provided
by the program writer (filename.c and filename.h) into machine code suitable for loading into the
processor.
Once the source files are provided to the compiler, the compiler executes two steps to render
the machine code. The first step is the compilation process. Here the program source files are
transformed into assembly code. If the program source files contains syntax errors, the compiler
reports these to the user. An assembly language program is not generated until the syntax errors have
been corrected.
The assembly language source file is then passed to the assembler.The assembler transforms the
assembly language source file to machine code suitable for loading to the MSP430 microcontroller.
The Texas Instrument Code Composer Studio provides a user friendly interface to aid in program
development, transformation to machine code, and loading into the MSP430 development board.
In the next section, we will discuss the components ofaCprogram.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required