Msp430 Example Code

Network TI E2E Community Silicon Errata Training and Events. Overview; MSP430 code examples C2000 code examples Stellaris® code examples.

In this tutorial we will learn MSP430 GPIO Programming. It is also applicable for MSP430x2xx devices like MSP430G2553, MSP430G2231, etc found on Launchpad Development board. Naval ship simulator freeware pdf file. Most of the pins on MSP430 Microcontrollers are grouped into a maximum of 8 Ports viz.

Each port is 8-bits wide and has eight associated I/O pins. These pins are directly mapped to the corresponding port registers and hence I/O pins can be manipulated independently. B lotus bold font. Only pins in Ports P1 and P2 support interrupts. Additionally, each I/O pin also has configurable pull-up and pull-down resistors.

Each port has an associated groups of registers used to manipulate its individual pins. The bit mapping and port grouping is as shown below. The naming convention(as used in the Manual/Datasheet) for Pins is ‘ Px.y’ where ‘ x’ is the port number (1 to 8) and ‘ y’ is simply the pin number (0 to 7) in port ‘ x’. For example: P1.1 refers to Pin number 1 of Port 1, P2.4 refers to Pin number 4 in Port 2. You will see the same conventions used to mark pins on your MSP430 Launchpad development board.

Current version of MSP430G2 Launchpad Ships with MSP430G2553 and MSP430G2452. Older version(Rev1.4) used to ship with MSP430G2231 and MSP430G2211. However, programming is same for all supported devices unless mentioned. GPIO Registers in MSP430 The GPIO block has many registers. We will only go through some of the digital I/O registers that are within the scope of this tutorial.

I will cover Interrupt related registers(viz. PxIFG, PxIES, PxIE) in a different tutorial. PxDIR: This is the GPIO direction control register. Setting any bit to 0 in this register will configure the corresponding Pin[0 to 7] to be used as an Input while setting it to 1 will configure it as Output. PxIN (Readonly): Used to Read values of the Digital I/O pins configured as Input. 0 = Input is LOW, 1 = Input is HIGH.

PxOUT: Used to directly write values to pins when pullup/pulldown resistors are disabled. 0 = Output is LOW, 1 = Output is HIGH. When pullup/pulldown resistors are enabled: 0 = Pin is pulled down, 1 = Pin is pulled up. RxREN: For pins configured as input, PxREN is used to enable pullup/down resistor for a given pin and PxOUT in conjunction with PxREN is used to select either Pullup or pulldown resistor. Setting a bit to 1 will enable pullup/down resistor for the corresponding pin while setting it to 0 will disable the same.

PxDIR PxREN PxOUT I/O Config 0 0 X Input with resistors disabled 0 1 0 Input with Internal Pulldown enabled 0 1 1 Input with Internal Pullup enabled 1 X X Output – PxREN has no effect 5. PxSEL & PxSEL2: Since most of the port pins are multiplexed with upto 4 different functions, we need a mechanism to select these functions. This is achived using PxSEL and PxSEL2 registers. The bit combinations of these registers for a particular pin will select a particular pin function. The bit combination is as given below: PxSEL2(nth bit) PxSEL(nth bit) Pin Function 0 0 GPIO (Digital I/O) Function 0 1 Primary Peripheral Function 1 0 Reserved. Consult device specific datasheet.