0% found this document useful (0 votes)
136 views35 pages

MSP430 - C7 - Course Lesson1 - MCU

The document discusses using the MSP430G2553 microcontroller for basic input/output applications. It provides code examples for blinking an LED connected to port 1 pin 0 by toggling the pin's output value. It also lists several common peripherals that can be controlled including LED 7-segment displays, LED matrices, LCD displays, and keypads. The document provides an overview of the MCU's registers for configuring port pins as general purpose I/O and controlling the pin direction, output, and pull-up/pull-down settings.

Uploaded by

Hải Nam
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
136 views35 pages

MSP430 - C7 - Course Lesson1 - MCU

The document discusses using the MSP430G2553 microcontroller for basic input/output applications. It provides code examples for blinking an LED connected to port 1 pin 0 by toggling the pin's output value. It also lists several common peripherals that can be controlled including LED 7-segment displays, LED matrices, LCD displays, and keypads. The document provides an overview of the MCU's registers for configuring port pins as general purpose I/O and controlling the pin direction, output, and pull-up/pull-down settings.

Uploaded by

Hải Nam
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

CU LC B NGHIN CU KHOA HC KHOA IN-IN T H BCH KHOA TP.

H CH MINH

MCUs & MSP430G2553


1
2

C programming & IDE CCS v5.2 GPIO in MSP430 Discussion & Homework

Requirement: a. Blink a LED every 1s b. Turn on a led when button is pushed c. Timer, ADC, UART, Interrupt, SPI, I2C d. .

Solution: Micro Controller Unit - Integrated circuits - Programmable

Peripherals P: MSP430, 8051,PIC,ARM,

UART Core: 8b, 16b, 32b,64b

GPIO

SPI

Timer

ADC

C: MSP430, LPC1114, PIC16F887,

Simple: hardware & software Enough: price , peripherals, Developing <-> TI Vietnam

16kB Flash 512B RAM 2 Timer_A3s 8 Ch. Comp_A+ 8 Ch. ADC10 USCI

http://www.ti.com/product/msp430g2553

Thin shrink small outline package

Low Supply-Voltage Range Package: o 1.8 V to 3.6 V TSSOP: 20 Pin, 28 Pin Ultra-Low Power Consumption PDIP: 20 Pin 16-Bit RISC Architecture, 62.5-ns Instruction Cycle Time QFN: 32 Pin Basic Clock Module Configurations o Internal Frequencies up to 16 MHz With Four Calibrated Frequency Quad flat no lead: dn o Internal Very-Low-Power Low-Frequency (LF) Oscillator o 32-kHz Crystal o External Digital Clock Source
http://www.ti.com/product/msp430g2553

Plastic dual in-line package: 2 hng

USB Emulator Connection

Embedded Emulation 6-pin eZ430 Connector

Crystal Pads
Chip Pinouts Part and Socket

P1.3 Button LEDs and Jumpers P1.0 & P1.6

Power Connector

Reset Button

http://www.ti.com/tool/msp-exp430g2

Debugger

MCU Debugger

MCU

I want

Programming in C

Compiler

Integrated development environment for TI embedded processors


Includes debugger, compiler, editor, simulator, OS The IDE is built on the Eclipse open source software framework Extended by TI to support device capabilities

Integrate additional tools


OS application development tools (Linux, Android) Code analysis, source control

Linux support Low cost! $445 or $495 (!)


-> Free code size limited for students

CCS IDE MSP430G2553

General Purpose Input/ Output

- Main MSP430G2553 - Chun b CCS, datasheet - Tuts : to project, GPIO

- Main MSP430G2553 - IDE - GPIO

-LCD - Keypad -Led matrix -Led 7 segment

- Nhy Led - Nt nhn

Cc Thanh ghi ny qui nh ch lm vic cho cc chn bao gm PxSEL v PxSEL2


0
0

VD: Ta mun port 1 l GPIO th ta thc hin lnh nh sau: P1SEL = 0; P1SEL2 = 0;

Lu : Interrupts P1 v P2 s b v hiu ha khi PxSEL=1


(!) Xem thm Datasheet: Port Schematics

Thanh ghi ny qui nh loi ng vo ra cho cc chn GPIO Mc nh tt c cc chn l input (0), khi cn i thnh output (1), ta t Bit tng ng trn thanh ghi l 1.

VD: P1DIR = 0x01

//pin P1.0 is output

Thanh ghi ny cho php tt hoc m ch pullup/pulldown resistor cho cc chn GPIO. Mc nh cc bit ca thanh ghi ny l 0.

Khi ta cn c gi tr t cc chn GPIO input, ta s c bit tng ng trn thanh ghi PxIN

Lu l ta phi chc rng bit tng ng ca GPIO trn thanh ghi PxDIR vn l 0 (input) trc khi c PxIN.

Khi ta mun xut in p trn cc chn Output, ta s t gi tr tng ng vo cc thanh ghi PxOUT (logic 1 -> VCC, logic 0 -> 0V)

Trong trng hp thanh ghi PxREN qui nh GPIO ch pullup/pulldown resistor th PxOUT qui nh:

Lu l ta phi chc rng bit tng ng ca GPIO trn thanh ghi PxDIR c set l 1 (output) trc khi xut mc logic ra.

thc hin xut / nhp trn 1 chn (Pin): - t ng gi tr cho thanh ghi PxDIR: 1:output; 0: input - t chc nng ca pin l GPIO hay cc chc nng khc qua thanh ghi PxSEL - Xut tn hiu bng cch ghi gi tr 0 hoc 1 vo thanh ghi OUT ca port tng ng (vd: P1OUT) - c gi tr ca chn bng cch c mc logic trn thanh ghi IN ca port tng ng (vd: P1IN) - Khi cn in tr ko ln/xung, t ng gi tr ca bit trn cc thanh ghi PxREN v PxOUT

#include <msp430g2553.h> // hay <msp430.h> //Khai bo bin ton cc unsigned int a //Khai bo chng trnh con void chuong_trinh_con(void) { //chng trnh con y }

//Chng trnh chnh void main(void) { // Phn khi to // vng lp v tn while(1) { //thc hin lnh };

#define BIT0 #define BIT1 #define BIT2 // . #define BITE #define BITF

(0x0001) (0x0002) (0x0004) . (0x4000) (0x8000)

Pin: low level --> LED On Pin: high level --> LED Off

//Blink a led connected with P1.0 #include <msp430g2553.h> // or <msp430.h> void main(void) { // unsigned int i; // declare variables WDTCTL = WDTPW + WDTHOLD; // Stop watch dog timer P1DIR |= BIT0 + BIT6; // Set P1.0 and P1.6 to output direction while(1) { P1OUT ^= BIT0 + BIT6; __delay_cycles(1000000); }

// Toggle P1.0 and P1.6 using exclusive-OR // Delay 1000000 Machine Cycles (MC=1us) // in IAR: _delay_cycles(1000000);

LED 7 Segment LED matrix 8x8 LCD 16x2 Keypad 4x4

END

You might also like