CS4101 嵌入式系統概論 General Purpose IO

Slides:



Advertisements
Similar presentations
Chapter 6 General Purpose Input/Output
Advertisements

Lab 1 I/O, timers, interrupts on the eZ430-RF2500 Thomas Watteyne EE290Q – Spring 2010
Outline MSP430 LaunchPad MSP430 Microcontroller
Chung-Ta King National Tsing Hua University
Chung-Ta King National Tsing Hua University
Chung-Ta King National Tsing Hua University
ECE 447 Fall 2009 Lecture 9: TI MSP430 Interrupts & Low Power Modes.
ECE 382 Lesson 2 Readings Lesson Outline Admin Assembler Linker
ECE Lecture 1 1 L15 – Digital I/O Department of Electrical and Computer Engineering The Ohio State University ECE 2560.
KEG-012 A.K.A. EMMA AND DAVE’S GROUPS Design Projects.
MSP430 Intro. Why embedded systems? Big bang-for-the-buck by adding some intelligence to systems. Embedded Systems are ubiquitous. Embedded Systems more.
CS4101 嵌入式系統概論 Timers and Clocks 金仲達教授 國立清華大學資訊工程學系 Materials from MSP430 Microcontroller Basics, John H. Davies, Newnes, 2008.
CS4101 嵌入式系統概論 Software UART Revisited Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan ( Materials from MSP430.
Chung-Ta King National Tsing Hua University
PIC microcontrollers. PIC microcontrollers come in a wide range of packages from small chips with only 8 pins and 512 words of memory all the way up to.
LAB 7: WDT+ and Low-Power Optimization
Development. Development Environment Editor Assembler or compiler Embedded emulator/debugger IAR Embedded Workbench Kickstart Code Composer Essentials.
A Simple Tour of the MSP430. Light LEDs in C LEDs can be connected in two standard ways. Active high circuit, the LED illuminates if the pin is driven.
BYU CS 124Lab 0 - Warm-up Lab1 Lab 0 – Warm-up Lab 1.Acquire a Texas Instruments MSP430 LaunchPad Development Tool. 2.Setup a CS user account. 3.Install.
1 ARM University Program Copyright © ARM Ltd 2013 General Purpose I/O.
Teachers Name : Suman Sarker Telecommunication Technology Subject Name : Microcontroller & Embedded System Subject Code : 6871 Semester : 7th Department.
1 ARM University Program Copyright © ARM Ltd 2013 General Purpose I/O.
Lecture 11: TI MSP430 Timers Compare Modes
1 LHO 13 The 8051CF020 and the University Daughter Card.
Lecturers: Professor John Devlin Mr Robert Ross
ECS642U Embedded Systems Cyclic Execution and Polling William Marsh.
IO Subsystem IV Ports and peripherals. IO Subsystem (1) All devices connected to the system buses, other than memory and CPU – Input and output ports.
ECE Lecture 1 1 L15 –I/O Part II Department of Electrical and Computer Engineering The Ohio State University ECE 2560.
Microcontroller based Traffic signal Umer Butt Amna Rashid Izza Rabbani Rozab Naveed Ramesha Akram.
MICROCONTROLLER INTERFACING WITH STEPPER MOTOR MADE BY: Pruthvirajsinh Jadeja ( ) COLLEGE:DIET BRANCH:EC.
Chapter 2 MSP432 ARM I/O Programming 1. Chapter Review Section 2.1: MSP432 Microcontroller and LaunchPad Section 2.2: GPIO (General Purpose I/O) Programming.
UNIT 2. CPUXV2 20-bit addressing User-definable Boot Strap Loader RAM starts at 0x1C00 Beginning of MAIN flash moves according to RAM Vector table starts.
National Tsing Hua University CS4101 嵌入式系統概論 Introduction to LaunchPad Prof. Chung-Ta King Department of Computer Science National Tsing Hua University,
ECE 382 Lesson 32 Lesson Outline Lab 6 Introduction Pulse Width Modulation Capture / Compare Example Lab 6 Tips Admin Lab#6 “prelab” due BOC lesson 33.
Outline Introduction to NuMaker TRIO Programming environment setup
Lab 7 Basic 1: Game of Memory
ECE 3430 – Intro to Microcomputer Systems
RASPBERRY PI WORKSHOP.
Introduction Why low power?
Introduction Why low power?
Peripherals – Keypad The Keypad provides a simple means of numerical data or control input. The keys can be attributed whatever data or control values.
Lecture 8: TI MSP430 Interrupts, ISRs
Everybody.
CS4101 嵌入式系統概論 Introduction to LaunchPad
Microcontroller basics
CS4101 Introduction to Embedded Systems Lab 10: Tasks and Scheduling
CS4101 嵌入式系統概論 Interrupts Prof. Chung-Ta King
Lesson Outline Interrupts Admin Assignment #9 due next lesson
CS4101 Introduction to Embedded Systems Lab 6: Low-Power Optimization
CS4101 Introduction to Embedded Systems Lab 1: MSP430 LaunchPad IDE
ECE 3430 – Intro to Microcomputer Systems
CS4101 嵌入式系統概論 Interrupts Prof. Chung-Ta King
Chapter 6 General Purpose Input/Output
CS4101 Introduction to Embedded Systems Lab 1: General Purpose IO
Lesson Outline Peripherals Memory-Mapped IO Ports GPIO Multiplexing
Prof. Chung-Ta King Department of Computer Science
CS4101 嵌入式系統概論 General Purpose IO
Arduino.
Blinking an LED Using MSP430ware to Control GPIO
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 2: Timer and Clock Prof. Chung-Ta King Department of Computer Science National.
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 3: Interrupt Prof. Chung-Ta King Department of Computer Science National Tsing.
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 6: Serial Communication Prof. Chung-Ta King Department of Computer Science National.
CS4101 Introduction to Embedded Systems Lab 4: Interrupt
CS4101 Introduction to Embedded Systems Lab 8: Arduino DAC and PWM
Lecture 9: TI MSP430 Interrupts & Low Power Modes
CS4101 Introduction to Embedded Systems Lab 2: Basic IO and Timer
Prof. Chung-Ta King Department of Computer Science
MSP430 Clock System and Timer
Speaker: Yu-Ju Cho 卓余儒 Advisor: Prof. An-Yeu Wu 吳安宇教授
A modular robot for use in the RoboSumo lab
Presentation transcript:

CS4101 嵌入式系統概論 General Purpose IO Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan Materials from MSP430 Microcontroller Basics, John H. Davies, Newnes, 2008

LaunchPad Development Board USB Emulator Connection Embedded Emulation 6-pin eZ430 Connector Crystal Pads Chip Pinouts Part and Socket P1.3 Button Power Connector LEDs P1.0 & P1.6 Reset Button

Recall: Sample Code for Output #include <msp430x2553.h> void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog P1DIR |= 0x41; // set P1.0 & 6 to outputs for(;;) { volatile unsigned int i; P1OUT ^= 0x41; // Toggle P1.0 & P1.6 i = 50000; // Delay do (i--); while (i != 0); }

Recall: Memory-Mapped I/O LED P1REN … P1IN P1OUT X No P3 for 20-pin devices MOV.W #0x100,P1OUT Go through all the components once and explain their meanings

Configuring the I/O Ports Registers (Mem Addr) Functions Descriptions P1IN (0x0020) Port 1 input This is a read-only register that reflects the current state of the port's pins. P1OUT (0x0021) Port 1 output The values written to this read/write register are driven out to corresponding pins when they are configured to output. P1DIR (0x0022) Port 1 data direction Bits written as 1 (0) configure the corresponding pins for output (input). P1SEL (0x0026) Port 1 function select Bits written as 1 (0) configure corresponding pins for use by the specialized peripheral (for general-purpose I/O). P1REN (0x0027) Port 1 resistor enable Bits set in this register enable  pull-up/down resistors on the corresponding I/O pins.

MSP430 GPIO GPIO = General Purpose Bit Input/Output 8-bit I/O ports Each pin is individually controllable Controlled by memory-mapped registers P1.7 P1.6 P1.5 P1.4 P1.3 P1.2 P1.1 P1.0 I/O Port 1 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0

PxDIR (Pin Direction): Input or Output PxDIR.y: 0 = input 1 = output Register example: P1DIR &= 0x81; P1IN.7 P1OUT.7 P1DIR.7 “1” 7 6 5 4 3 2 1 P1IN P1OUT P1DIR

GPIO Output PxOUT.y: 0 = low 1 = high Register example: P1OUT &= 0x80; P1IN.7 P1OUT.7 P1DIR.7 “1” “1” “1” 7 6 5 4 3 2 1 P1IN X P1OUT P1DIR

Sample Code for Input (MSP430g2553) #include <msp430g2553.h> #define LED1 BIT0 //P1.0 to red LED #define B1 BIT3 //P1.3 to button void main(void){ WDTCTL = WDTPW + WDTHOLD; //Stop watchdog timer P1OUT |= LED1 + B1; P1DIR = LED1; //Set pin with LED1 to output P1REN = B1; //Set pin to use pull-up resistor for(;;){ //Loop forever if((P1IN & B1) ==0){ //Is button down? P1OUT &= ~LED1; // Yes, turn LED1 off } else{ P1OUT |= LED1; // No, turn LED1 on } } P1OUT is not initialized and must be written before configuring the pin for output. Assume button is active low (0  pressed; 1  depressed)

Problem with Input Using a Button When the button is pressed down (closed), MSP430 will detect a 0 from the pin. When the button is up (open), what will MSP430 detect? Ans.: random value  Floating

Typical Way of Connecting a Button The pull-up resistor Rpull holds input at logic 1 (voltage VCC) while button is up and logic 0 or VSS when button is down  active low A wasted current flows through Rpull to ground when button is down This is reduced by making Rpull large enough, typically 33 k

Typical Way of Connecting a Button MSP430 offers internal pull-up/down PxREN register selects whether this resistor is used (1 to enable, 0 to disable) When enabled, the corresponding bit of PxOUT register selects whether the resistor pulls the input up to VCC (1) or down to VSS (0)

GPIO Input P1IN.7 P1OUT.7 P1DIR.7 up/down P1REN.7 P1IN P1OUT Enable resistor Input pins are held in high-impedance (Hi-Z) state, so they can react to 0 or 1 When not driven, Hi-Z inputs may float up/down … prevent this with pullup/pulldown resistors PxREN enables resistors PxOUT selects pull-up (1) or -down (0) Lower cost devices may not provide up/down resistors for all ports 7 6 5 4 3 2 1 P1IN x P1OUT P1DIR P1REN