当前位置:
文档之家› 嵌入式系统教案-接入输出(全英)
嵌入式系统教案-接入输出(全英)
High Impendence Input
Question
• Pins 0-7 of port 1 need to have the following characteristics:
1. Input with pull up resistor 2. Output
• Write down values for P1DIR, P1REN P1OUT for each configuration.
Typical characteristics
• At a Vcc of 3V
– High > 2.25V – Low < 0.75V
• The higher the drive current, the greater the voltage drop on Vcc.
– To keep this within 0.6V at Vcc = 3V, keep sink/source current < 5mA.
Double Pole, Double Throw (DPDT)
Connection
Higher order combinations (ie.e 6PST)
Development Board Connections
Two SPST Switches, normally open
Accessing GPIO in C
– Base 16 rather than base 10. – Typically denoted 0x## for 8
bit, 0x#### for 16 bit etc
• TIP – Use Windows Calculator to convert from hex to binary and back.
• GPIO’s are arranged in 8 bit ports, i.e. • P1.0, P1.1, P1.2… P1.7 • We need to configure PxDIR, PxREN, PxOUT where x is
the port. • First bit corresponds to pin 0, last bit to pin 8. • P1DIR = 0x0F makes first 4 pins of port 1 an output.
PxOUT
High (1)
Output
Enable pull up/down
High out / pull up
Low (0)
Input
Disable pull up/down
Low out / pull down
Pin
PxREN
3.3V
PxDIR || PxREN
0
1
1
PxOUT
0
GND
10
35kW
EE312 Instrumentation and Microcontrollers
Lecture 2: Digital IO
What you will learn
• MSP430 port structure
• How to create a digital output • Driving an LED • Sinking and sourcing current • How to create a digital input • Switch debouncing
• Peripheral functions include address, data and control lines for external memory, external interrupts, analogue I/O, serial I/O, clocks
GPIO Layout
Register PxDIR PxREN
Register PxDIR PxREN
PxOUT
High (1)
Output
Enable pull up/down
High out / pull up
Low (0)
Input
Disable pull up/down
Low out / pull down
Accessing GPIO in C
• Is everyone familiar with hex encoding?
– Total output from all ports should not exceed 48 mA.
Typical characteristics
• At a Vcc of 3V – High > 2.25V – Low < 0.75V
Connecting an LED
• Question: Please draw the circuit to connect an LED to a digital output pin.
Connecting an LED
3.3V
Px
Px
Px
Px
GND
Connecting multiple LEDs
Connecting Multiple LEDs
• Question: Can we make all 8 LEDs turn on at once?
Connecting a Switch
What you will learn
Basic I/O Ports
• The MSP430FR4133 can have up to 8 8 bit I/O ports (some not available to users)
• Pins function as I/O ports or as peripheral function I/O
Connecting a Switch
• Question: What will be the logic level of the switch when pressed (the switch is normally open)?
Types of Switch
Switch Type Single Pole Single Throw (SPST) Single Pole, Double Throw (SPDT) Double Pole, Single Throw (DPDT)