Network and Systems Laboratory nslab.ee.ntu.edu.tw.

Slides:



Advertisements
Similar presentations
CH14 BIPOLAR DIGITAL CIRCUITS The Ideal BJT Transistor Switch
Advertisements

1 ECE 372 – Microcontroller Design Parallel IO Ports - Outputs Parallel IO Ports E.g. Port T, Port AD Used to interface with many devices Switches LEDs.
Week10 Boolean Instructions on the Boolean Instructions  Boolean (or Bit) addressable capability is unique to the 8051  Enables efficient handling.
Input/Output Ports and Interfacing ELEC 330 Digital Systems Engineering Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning.
Transistors Fundamentals Common-Emitter Amplifier What transistors do
Instructor Name: (Your Name)
Announcements Troubles with Assignments… –Assignments are 20% of the final grade –Exam questions very similar (30%) Deadline extended to 5pm Fridays, if.
Digital I/O Connecting to the Outside World
Lecture – 7 Basic input and output
Chapter 1 Quick review over Electronics and Electric Components Prepared By : Elec Solv.
ECE 447 Fall 2009 Lecture 6: TI MSP430 IO Interfacing.
ECE 447: Lecture 6 Input/Output Interfacing LEDs, Button Switches & Port Multiplexing.
As an Astable Multivibrator.  An integrated chip that is used in a wide variety of circuits to generate square wave and triangular shaped single and.
BASIC ELECTRONICS.
Network and Systems Laboratory nslab.ee.ntu.edu.tw.
Microprocessor Block Diagram
UNIVERSAL COLLEGE OF ENGINEERING &TECHNOLOGY DIGITAL ELECTRONICS SUBJECT - DIGITAL ELECTRONICS.
Introduction to Transistors
Objectives How Microcontroller works
Astable Multivibrator
Input/Output Ports and Interfacing
BJT Amplifiers (cont’d)
DMT 121 – ELECTRONIC DEVICES
1 ARM University Program Copyright © ARM Ltd 2013 General Purpose I/O.
One of the most important feature of the microcontroller is a number of input/output pins used for connection with peripherals. In the case of PIC 167CX,
Power Amplifiers Unit – 4.1 Classification of Power Amplifiers  Power amplifiers are classified based on the Q point  If the operating point is chosen.
1 ARM University Program Copyright © ARM Ltd 2013 General Purpose I/O.
CHAPTER 4 The Bipolar Transistor. OBJECTIVES Describe and Analyze: Transistor architecture Transistor characteristics Transistors as switches Transistor.
Chapter 5 Transistor Bias Circuits
Electronic Components. Battery A portable power source that has a positive and negative. Electronics works on Direct Current (DC) where electrons flow.
Lecturers: Professor John Devlin Mr Robert Ross
Engineering 1040: Mechanisms & Electric Circuits Winter 2015 Interfacing Light-Emitting Diodes (LEDs) & Push Buttons to Microcontrollers.
ECS642U Embedded Systems Cyclic Execution and Polling William Marsh.
1 ECE 372 – Microcontroller Design Parallel IO Ports - Inputs.
Chapter 6 Voltage Regulators - Part 2-.
Automatic accident avoiding system PROJECT MEMBERS MUTHUKUMAR.K (05ME33) SAKTHIDHASAN.S (05ME39) SAKTHIVEL.N (05ME40) VINOTH.S (05ME56) PROJECT GUIDE:
Chapter 4 Bipolar Junction Transistors
Chapter 5 Transistor Bias Circuits
ECES 352 Winter 2007Ch. 7 Frequency Response Part 31 Common-Base (CB) Amplifier *DC biasing ● Calculate I C, I B, V CE ● Determine related small signal.
ECE Lecture 1 1 L15 –I/O Part II Department of Electrical and Computer Engineering The Ohio State University ECE 2560.
Network and Systems Laboratory nslab.ee.ntu.edu.tw.
Lab 3: ADC.
Mark Neil - Microprocessor Course 1 Decoding and Using a 4x4 Keyboard.
Chapter 3 – Transistor Amplifiers – Part 2 Special Amplifiers 1.Difference Amplifier 2.Complementary Symmetry 3.Cascading.
Self Switching Power Supply. Introduction Self Switching Power Supply  Embedded system requires a regulated power supply.
Prepared by: Garima Devpriya ( ) Jamila Kharodawala ( ) Megha Sharma ( ) ELECTRONICS DEVICES AND CIRCUITS G.H.Patel.
ACCURATE ELECTRONIC STOPWATCH
Chapter 4 Bipolar Junction Transistors
1 Lawndale High School AWIM Program Transistor Theory & Experiment Lecture 5.
Application Case Study Christmas Lights Controller
ARDUINO BASED UNDERGROUND CABLE FAULT DETECTION
Embedded Systems Programming (What they do and when / how to use them)
Microcontrollers, Basics Tips and Tricks with PIC MCUs
Peripherals – Keypad The Keypad provides a simple means of numerical data or control input. The keys can be attributed whatever data or control values.
Projekt Anglicky v odborných předmětech, CZ.1.07/1.3.09/
REMOTE JAMMING DEVICE.
Electronic Devices Ninth Edition Floyd Chapter 17.
SELF SWITCHING POWER SUPPLY
SELF SWITCHING POWER SUPPLY
Chapter 6 General Purpose Input/Output
Lecture 6: TI MSP430 IO Interfacing
Principles & Applications Small-Signal Amplifiers
Lesson 9: Digital Input-Output Signal Interfacing
Components and Schematics
Presented by: Sanjay Pithadia SEM – Industrial Systems, Medical Sector
Electronics Fundamentals
Keypad Source: under under
Bipolar Transistors AIM:
CHAPTER 59 TRANSISTOR EQUIVALENT CIRCUITS AND MODELS
Presentation transcript:

Network and Systems Laboratory nslab.ee.ntu.edu.tw

Network and Systems Laboratory nslab.ee.ntu.edu.tw GPIO on MSP430 6 ports on MS430F1611 Port 1 Port 2 Port 3 Port 4 Port 5 Port 6 Each port has 8 pins Px.0 ~ Px.7

Network and Systems Laboratory nslab.ee.ntu.edu.tw Multiplexed Port pins are often multiplexed Means it may have more than one function Example: P1.0/TACLK It can be P1.0 GPIO Or it can be TACLK You must select the function you want

Network and Systems Laboratory nslab.ee.ntu.edu.tw Each pin can be configured as input or output When set to output You can configure it to be High: voltage is Vcc (Supply voltage) Low: voltage is GND (Ground) High: 3.3V Select Direction Low: 0V

Network and Systems Laboratory nslab.ee.ntu.edu.tw Input When you select a pin as input direction, a corresponding bit in peripheral register will Set to 0 when input voltage is low Set to 1 when input voltage is high High: 3.3V Low: 0V 1 0

Network and Systems Laboratory nslab.ee.ntu.edu.tw Interrupts Only P1 and P2 are interruptible For each pin in P1 and P2, you can enable or disable its interrupt Enable means it will detects interrupt Disable means nothing happen when interrupt occur

Network and Systems Laboratory nslab.ee.ntu.edu.tw How to Detect Interrupts For GPIO, interrupt is detected when a transition occur Low to high transition: High to low transition: You must define which one you want to detect 0 V 3.3 V 0 V 3.3 V

Network and Systems Laboratory nslab.ee.ntu.edu.tw Interrupt Flag When the MCU detects an interrupt A corresponding bit in peripheral register will set to 1 Branch to ISR You must clear the GPIO interrupt flag in software Means you must set the bit to 0 or the program will re-enter the ISR again

Network and Systems Laboratory nslab.ee.ntu.edu.tw GPIO Registers Each GPIO port has four registers Input: P x IN Output: P x OUT Direction: P x DIR Port Select(function select): P x SEL P1 and P2 have three more Interrupt flag: P x IFG Interrupt edge select: P x IES Interrupt enable: P x IE Each register is 8-bit long x represent the port number

Network and Systems Laboratory nslab.ee.ntu.edu.tw How to Select Function You want to select this pin as GPIO(P1.0) function The register related to function select Port Select(function select): P x SEL This is port 1, so the related register is P1SEL From user guide

Network and Systems Laboratory nslab.ee.ntu.edu.tw How to Select Function P1SEL is 8-bit long Each bit corresponding to a pin in the port P1SEL xxxxxxxx 07 P1.0/TACLK P1.1/TA0 P1.2/TA1 P1.3/TA2 P1.4/SMCLK P1.5/TA0 P1.6/TA1 P1.7/TA2

Network and Systems Laboratory nslab.ee.ntu.edu.tw How to Select Function You want select P1.0/TACLK as P1.0 Set the corresponding bit to 0 In C: P1SEL = P1SEL & 0xFE; P1SEL xxxxxxxx 07 P1.0/TACLK P1.1/TA0 P1.2/TA1 P1.3/TA2 P1.4/SMCLK P1.5/TA0 P1.6/TA1 P1.7/TA2 P1SEL xxxxxxx0 07

Network and Systems Laboratory nslab.ee.ntu.edu.tw Setting Bits P1SEL = P1SEL & 0xFE; P1SEL &= 0xFE; Usually, we use hexadecimal in setting registers 0xFE = (binary number) Why P1SEL &= 0xFE; Why not P1SEL = 0xFE; The other registers are similar check user guide Hexadecimal

Network and Systems Laboratory nslab.ee.ntu.edu.tw GPIO Interrupt All P1 pins source a single interrupt vector, and all P2 pins source a different single interrupt vector. Interrupts generated by P1.0, P1.1, …, P1.7 all go to same ISR How do you know which one generate the interrupt check interrupt flag

Network and Systems Laboratory nslab.ee.ntu.edu.tw Hardware LEDs Switches Keypad

Network and Systems Laboratory nslab.ee.ntu.edu.tw LEDs This is a typical connection When P1.1 set to high DVcc = V P1.1 no current flow When P1.1 set to low V P1.1 = 0 Current flow through, turn on the LED GPIO can use as an On/Off control DVcc V anode V cathode R

Network and Systems Laboratory nslab.ee.ntu.edu.tw Control LEDs Look at Taroko schematic which pins the LEDs connected to These pins should be input direction or output direction? How to set these pins to high (or low)

Network and Systems Laboratory nslab.ee.ntu.edu.tw Will This Work Maybe, but you shouldn’t do this V anode V cathode R

Network and Systems Laboratory nslab.ee.ntu.edu.tw Max Current Source/Sink Each pin has a maximum amount of current it can provide(source) or accept(sink) For MSP430 Max source: 6mA Max sink: 6mA Usually it can sink more current than it can source You cannot use those pin as a power source (or sink) for any sensor/circuit directly

Network and Systems Laboratory nslab.ee.ntu.edu.tw Transistors One of the fundamental building block of ICs Two type: NPN, PNP B : Base C : Collector E : Emitter We will talk about NPN transistor most commonly used

Network and Systems Laboratory nslab.ee.ntu.edu.tw Functional Model A base current I B flows only when the voltage V BE across the base-emitter junction is 0.7V or more Ic = h FE × I B (h FE is current gain) The collector-emitter resistance R CE is controlled by the base current I B : I B = 0 R CE = infinity transistor off I B small R CE reduced transistor partly on I B increased R CE = 0 transistor full on ('saturated')

Network and Systems Laboratory nslab.ee.ntu.edu.tw Transistor as An On/Off Switch Application Circuit  Load is turn on when chip output is high Choose a proper transistor and base resistor R B

Network and Systems Laboratory nslab.ee.ntu.edu.tw How To Choose Transistor Two parameter: Ic and h FE Ic(max) must be larger than I load (Ic) Ic = h FE × I B h FE(min) > 5 x ((Ic) /(maximum output current from the chip)) R B R B = (Vcc × h FE ) / (5 × Ic) choose the nearest standard value resistor

Network and Systems Laboratory nslab.ee.ntu.edu.tw Switches Operation Open: A and B are not connected in normal state Close: When you press the button, A and B are connected Typical circuit When the switch is open, voltage of USERINT stay at high When the switch is close, voltage of will be low A B

Network and Systems Laboratory nslab.ee.ntu.edu.tw Pull-up Resistor R4 is a pull-up resistor keep USERINT at high What if we don’t have R4 When it is open, USERINT is still high When it is close Short circuit USERINT

Network and Systems Laboratory nslab.ee.ntu.edu.tw Typical Value Typical value of pull-up resistor 10K ohm, 47K ohm, 100K ohm Amount of current flow through when it close I = V/R; Vcc = 3.3V, R = 10K ohm I = A = 330 μA 330 μA, does it matter for some type of switch, it is ok close time very short but not all, eg. reed switch

Network and Systems Laboratory nslab.ee.ntu.edu.tw Value of Pull-up To save power, can we use very large pull-up resistor? ans: No

Network and Systems Laboratory nslab.ee.ntu.edu.tw Impedance Resistance: R = V/I relation ship between the magnitude of the voltage and current Impedance: Z = V/I (there are complex number) relation ship between the magnitude and phase of the voltage and current

Network and Systems Laboratory nslab.ee.ntu.edu.tw Input Impedance Z RiRi R1R1 RiRi Vcc This is a simplified analysis, we consider impedance as a resistance. Impedance is more complex than a simple resistance

Network and Systems Laboratory nslab.ee.ntu.edu.tw Resistors in series R i is the input impedance of MSP430 GPIO pin TI didn’t specify its value but it should be larger than 10M ohm R 1 is pull-up resistor if R 1 is too large – R 1 = R i then V MCUpin = Vcc / 2 it is no longer a high state R1R1 RiRi Vcc V MCUpin

Network and Systems Laboratory nslab.ee.ntu.edu.tw Debounce Capacitor C9 is a debounce capacitor Bounces It could generate more than one interrupts when the switch is pressed

Network and Systems Laboratory nslab.ee.ntu.edu.tw HW/SW debounce Hardware debounce Capacitor will charge when the switch is open, and it will discharge when the switch is close (pressed) Pros: smooths the line Cons: increase the response time Software debounce Delay some time in the ISR How long you have to try out

Network and Systems Laboratory nslab.ee.ntu.edu.tw Keypad This is a 3x4 matrix keypad When you press a button, a pin in X and a pin in Y is connected How to interface to MSP430?

Network and Systems Laboratory nslab.ee.ntu.edu.tw Today’s Labs 1. Flash a LED on Taroko 2. Toggle a LED when UserInt switch on Taroko pressed 3. Control on/off of a LED by UserInt switch, control another by reed switch 4. (Extra Credit) Connected a 3x4 Keypad to Taroko, flash the LEDs RedGreenYellow Flash once Flash twice

Network and Systems Laboratory nslab.ee.ntu.edu.tw JTAG Driver C:\Program Files\IAR Systems\Embedded Workbench Evaluation 4.0\430\drivers\TIUSBFET\WinXP

Network and Systems Laboratory nslab.ee.ntu.edu.tw IAR Setting

Network and Systems Laboratory nslab.ee.ntu.edu.tw IAR Setting

Network and Systems Laboratory nslab.ee.ntu.edu.tw

Network and Systems Laboratory nslab.ee.ntu.edu.tw

Network and Systems Laboratory nslab.ee.ntu.edu.tw

Network and Systems Laboratory nslab.ee.ntu.edu.tw

Network and Systems Laboratory nslab.ee.ntu.edu.tw

Network and Systems Laboratory nslab.ee.ntu.edu.tw

Network and Systems Laboratory nslab.ee.ntu.edu.tw

Network and Systems Laboratory nslab.ee.ntu.edu.tw