Parallel ports, power supply, and the clock oscillator Chapter Three Dr. Gheith Abandah 1 Outline • Parallel ports – Technical challenges – Connecting to the parallel port – The PIC 16F84A parallel ports • Power supply • Clock oscillator Dr. Gheith Abandah 2 Data Transfer • Almost any embedded system needs to transfer digital data between its CPU and the outside world. – Direct user interface, including switches, keypads, lightemitting diodes (LEDs) and displays – Input measurement information, from external sensors, possibly being acquired through an analog-to-digital converter – Output control information, for example to motors or other actuators – Bulk data transfer to or from other systems or subsystems, moving in serial or parallel form, for example sending serial data to an external memory. Dr. Gheith Abandah 3 Output Parallel Ports Dr. Gheith Abandah 4 Input Parallel Ports Dr. Gheith Abandah 5 Bi-directional Parallel Ports Dr. Gheith Abandah 6 Port electrical characteristics Modeling a logic gate output. (a) Generalized model. (b) Model of CMOS logic gate output Dr. Gheith Abandah 7 Schmitt trigger inputs Schmitt trigger characteristics. (a) Buffer with Schmitt trigger input. (b) Input/output characteristic Dr. Gheith Abandah 8 The ‘Open Drain’ output (a) An ‘Open Drain’ output. (b) Open Drain output driving load resistor. (c) The ‘WiredOR’ connection Dr. Gheith Abandah 9 Connecting to the parallel port (1) Switches (a) SPDT connection. (b) SPST with pull-up resistor. (c) SPST with pull-down resistor Pull-up values in the range 10–100 kΩ Dr. Gheith Abandah 10 Connecting to the parallel port (2) Light-emitting diodes Dr. Gheith Abandah 11 Connecting to the parallel port (2) Light-emitting diodes Driving LEDs from logic gates. (a) Gate output sourcing current to LED (b) Gate output sinking current from LED Dr. Gheith Abandah 12 Connecting to the parallel port (2) Light-emitting diodes Dr. Gheith Abandah 13 The PIC 16F84A parallel ports • Port A – 5 Bits – RA3:RA0 – RA4/T0CKI • Port B – 8 Bits – RB0/INT – RB3:RB1 – RB7:RB4: Interrupt on change Dr. Gheith Abandah 14 Dr. Gheith Abandah 15 Dr. Gheith Abandah 16 Dr. Gheith Abandah 17 Dr. Gheith Abandah 18 Port output characteristics -1 R = 130 Ω VOH vs. IOH (VDD = 3V, −40 to 125◦C) Dr. Gheith Abandah 19 Port output characteristics -2 VOL vs. IOL (VDD = 3V, −40 to 125◦C) R = 36 Ω Dr. Gheith Abandah 20 The clock oscillator • Faster clock gives faster execution, but more power consumption. • The clock oscillator must give stable and accurate clock signal. • Oscillator types: – Resistor–capacitor (RC) • Not precise – Crystal or ceramic • Precise frequency, fragile, should be near the MC Dr. Gheith Abandah 21 Oscillator types (a) Resistor–capacitor (RC). Dr. Gheith Abandah (b) Crystal or ceramic 22 The 16F84A clock oscillator • Types: 1) XT – crystal: 1-4 MHz 2) HS – high speed: >= 4 MHz, with ceramic resonators. 3) LP – low power: <= 200 KHz, e.g., 32.768 kHz (i.e. 215), 4) RC – resistor-capacitor Dr. Gheith Abandah 23 (a) Crystal or ceramic, HS, XT or LP. (b) Resistor– capacitor. (c) Externally supplied clock Dr. Gheith Abandah 24 Data Sheet Information Dr. Gheith Abandah 25 Power Supply RC Oscillator 100 nF decoupling capacitor Dr. Gheith Abandah 26 Dr. Gheith Abandah 27 16F84A operating conditions Summary – 1 • The parallel port allows ready exchange of digital data between the outside world and the controller CPU. • It is important to understand the electrical characteristics of the parallel port and how they interact with external elements. • While there is considerable diversity in the logic design of ports, they tend to follow similar patterns. • The internal circuitry is worth understanding, as it leads to effective use of ports. • The 16F84A has diverse and flexible parallel ports. Dr. Gheith Abandah 28 Summary – 2 • A microcontroller needs a clock signal in order to operate. The characteristics of the clock oscillator determine speed of operation and timing stability, and strongly influence power consumption. Active elements of the oscillator are usually built in to a microcontroller, but the designer must select the oscillator type, and its frequency and configuration. • A microcontroller needs a power supply in order to operate. The requirements need to be understood and must be met by a supply of the appropriate type. Dr. Gheith Abandah 29