Steve Underwood - Harvard University

  • View
    221

  • Download
    0

Embed Size (px)

Text of Steve Underwood - Harvard University

  • 8/12/2019 Steve Underwood - Harvard University

    1/55

    mspgcc

    A port of the GNU tools to the Texas Instruments

    MSP430 microcontrollers

    Steve Underwood

  • 8/12/2019 Steve Underwood - Harvard University

    2/55

    mspgccA port of the GNU tools to the Texas Instruments MSP430 microcontrollers

    by Steve Underwood

    Copyright 2003 Steve Underwood

    This document can be freely redistributed according to the terms of the GNU General Public License.

  • 8/12/2019 Steve Underwood - Harvard University

    3/55

    Table of Contents1. What is mspgcc?.................................................................................................................................................1

    The GNU Binutils..........................................................................................................................................1

    The GNU GCC C Compiler ...........................................................................................................................1

    The GNU GDB and Insight debuggers.......................................................................................................... 1Extras..............................................................................................................................................................2

    2. Installing mspgcc................................................................................................................................................3

    Windows installation ......................................................................................................................................3

    RedHat Linux installation.............................................................................................................................. 3

    Installation on other platforms....................................................................................................................... 3

    3. An introduction to the TI MSP430 low-power microcontrollers...................................................................4

    Overview ........................................................................................................................................................4

    The memory map...........................................................................................................................................4

    The register set ...............................................................................................................................................4

    The available addressing modes.....................................................................................................................5

    Byte and word issues ......................................................................................................................................7The instruction set ..........................................................................................................................................7

    Instruction timing .........................................................................................................................................10

    Interrupts......................................................................................................................................................11

    The hardware multiplier ...............................................................................................................................12

    Low power modes........................................................................................................................................13

    Programming the flash memory ...................................................................................................................13

    Decoding part numbers................................................................................................................................ 14

    4. MSP430 specific extensions to the GNU toolchain........................................................................................16

    Compiler options ..........................................................................................................................................16

    Compiler defined symbols............................................................................................................................17

    The mspgcc header files ...............................................................................................................................17Function attributes ........................................................................................................................................17

    Writing interrupt service routines................................................................................................................ 18

    Customising the interrupt vector table .........................................................................................................19

    Controlling interrupt processing...................................................................................................................20

    Data types and memory handling.................................................................................................................20

    Accessing the MSP430s peripheral registers - the SFRs............................................................................ 21

    Reserving space above the stack..................................................................................................................22

    Handling the status register ..........................................................................................................................22

    The standard library functions......................................................................................................................23

    Starting from reset ........................................................................................................................................24

    Redefining the startup procedure..................................................................................................................26Redefining the end up procedure..................................................................................................................27

    Initializing the stack.....................................................................................................................................28

    5. mspgccs ABI ....................................................................................................................................................31

    Register usage...............................................................................................................................................31

    Function calling conventions........................................................................................................................31

    Fixed argument lists............................................................................................................................31

    Variable argument lists ....................................................................................................................... 31

    Return values ......................................................................................................................................32

    Call definitions.............................................................................................................................................32

    Assembler extensions ...................................................................................................................................33

    iii

  • 8/12/2019 Steve Underwood - Harvard University

    4/55

    6. Using inline assembly language in C programs with mspgcc ......................................................................34

    Inline assembly language syntax..................................................................................................................34

    Registers, variables and labels......................................................................................................................36

    Library calls..................................................................................................................................................37

    7. Tips and trick for efficient programming ......................................................................................................39

    8. Hardware tools .................................................................................................................................................41

    What is available?.........................................................................................................................................41

    Setting up the JTAG interface...................................................................................................................... 41

    Parallel port issue with Windows .................................................................................................................41

    Parallel port issues with Linux .....................................................................................................................41

    MSP430 evaluation and prototyping cards...................................................................................................42

    9. Compiling and linking MSP430 programs ........................................................................