Lecture (02) PIC16F84 (I) By: Dr. Ahmed ElShafee ١ Review of Memory Technologies The PIC 16 Series PIC 16F84A The PIC 16F84A Memory The Oscillator Instruction Cycle Power up and Reset Parallel ports Technical challenges Connecting to the parallel port The PIC 16F84A parallel ports Power supply Clock oscillator ٢
PIC Microcontrollers Peripheral Interface Controller (PIC) was originally designed by General Instruments In the late 1970s, GI introduced PIC 1650 and 1655 RISC with 30 instructions. PIC was sold to Microchip Features: low cost, self contained, 8 bit, Harvard structure, pipelined, RISC, single accumulator, with fixed reset and interrupt vectors. ٣ PIC Families C implies CMOS technology; Complementary Metal Oxide Semiconductor F insert indicates incorporation of Flash memory technology Example: 16C84 was the first of its kind. It was later reissued as the 16F84, incorporating Flash memory technology. It was then reissued as Dr. 16F84A. Ahmed ElShafee, ACU : Fall 2017, MicroControllers ٤ PIC Family Stack Size Instruction Word Size No of Instructions Interrupt Vectors 12CX/12FX 2 12 or 14 bit 33 None 16C5X/16F5X 2 12 bit 33 None 16CX/16FX 8 14 bit 35 1 17CX 16 16 bit 58 4 18CX/18FX 32 16 bit 75 2
12 Series PIC ٥ ٦
PIC 12F675 Architecture ٧ The PIC 16 Series Device Pins Clock Memory Features 16F84A 18 20 MHz 1 K ROM 68 B RAM 64 B EEPROM 16LF84A 16F84A 04 4 MHz 1 8 bit timer 1 5 bit port 1 8 bit port Extended supply voltage range ٨
Device Pins Clock Memory Features 16F873A 28 20 MHz 4 K ROM 192 B RAM 128 B EEPROM 16F874A 40 20 MHz 4 K ROM 192 B RAM 128 B EEPROM 3 parallel ports, 3 counter/timers, 2 capture/compare/pwm, 2 serial, 5 10 bit ADC, 2 comparators 5 parallel ports, 3 counter/timers, 2 capture/compare/pwm, 2 serial, 8 10 bit ADC, 2 comparators ٩ Device Pins Clock Memory Features 16F876A 28 20 MHz 8 K ROM 368 B RAM 256 B EEPROM 16F877A 40 20 MHz 8 K ROM 368 B RAM 256 B EEPROM 3 parallel ports, 3 counter/timers, 2 capture/compare/pwm, 2 serial, 5 10 bit ADC, 2 comparators 5 parallel ports, 3 counter/timers, 2 capture/compare/pwm, 2 serial, 8 10 bit ADC, 2 comparators ١٠
16F84A ١١ PIC 16F84A Architecture ١٢
The 16F84A Status Register C: Carry/Borrow DC: Digit Carry/Borrow Z: Zero PD : Power Down TO : Time Out RP0: Register Bank Select RP1, IRP: Not implemented ١٣ The 16F84A Memory Memory Technology Size Features Program Flash 1K x 14 bits Data (File Registers) SRAM 68 Bytes Data (EEPROM) EEPROM 64 Bytes Stack SRAM 8 x 13 bits 10,000 erase/write cycles Retains data down to 1.5 V 10,000,000 erase/write cycles ١٤
Program Memory and Stack ١٥ Configuration Word Allows the user to define certain configurable features of the microcontroller, at the time of program download. ١٦
Data memory and Special Function Registers FSR: File Select Register for indirect addressing. EEADR: EEPROM Address EEDATA: EEPROM Data EECON1: Control; RD, WREN, WR, EEIF EECON2: 55 H to AA H ١٧ The Oscillator It is necessary to provide the clock signal. The clock is a continuously running fixed frequency logic square wave. The overall speed of the microcontroller operation is entirely dependent on this clock frequency. Higher frequency > Higher Performance and higher power consumption. ١٨
Instruction Cycle The main oscillator signal is divided by 4 to produce the instruction cycle time. ١٩ Pipelining All PIC microcontrollers implement pipelining. Pipelining fails when one instruction changes the contents of the Program Counter. ٢٠
Power up and Reset At power up, the Program Counter is forced to zero and the SFRs are reset so that peripherals are initially in a safe and disabled state. There is also a master clear input MCLR. ٢١ Summary The PIC 16 Series is a diverse and effective family of microcontrollers. The 16F84A architecture is representative of all 16 Series microcontrollers, with Harvard structure, pipelining and a RISC instruction set. The PIC 16F84A has a limited set of peripherals, chosen for small and low cost applications. It is thus a smaller member of the family, with features that are a subset of any of the larger ones. The 16F84A uses three distinct memory technologies for its different memory areas. A particular type of memory location is the Special Function Register, which acts as the link between the CPU and the peripherals. Reset mechanisms ensure that the CPU starts running when the appropriate operating conditions have been met, and can be used to 22 restart the CPU in case of program failure.
Data Transfer Almost any embedded system needs to transfer digital data between its CPU and the outside world. 23 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. Output Parallel Ports 24
Input Parallel Ports 25 Bi directional Parallel Ports 26
Port electrical characteristics Modeling a logic gate output. (a) Generalized model. (b) Model of CMOS logic gate output 27 Schmitt trigger inputs Schmitt trigger characteristics. (a) Buffer with Schmitt trigger input. (b) Input/output characteristic 28
In electronics, a Schmitt trigger is a comparator circuit with hysteresis implemented by applying positive feedback to the noninverting input of a comparator or differential amplifier. It is an active circuit which converts an analog input signal to a digital output signal. ٢٩ The Open Drain output (a) An Open Drain output. (b) Open Drain output driving load resistor. (c) The Wired- OR connection 30
Connecting to the parallel port (1) Switches 31 (a) SPDT connection (single pole double throw). (b) SPST with pull-up resistor (single pole single throw). (c) SPST with pull-down resistor Pull-up values in the range 10 100 kω Connecting to the parallel port (2) Light emitting diodes 32
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 33 Connecting to the parallel port (2) Light emitting diodes 34
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 35 36
37 38
39 Port output characteristics 1 R = 130 Ω VOH vs. IOH (VDD = 3V, 40 to 125 C) 40
Port output characteristics 2 VOL vs. IOL (VDD = 3V, 40 to 125 C) R = 36 Ω 41 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 42
Oscillator types (a) Resistor capacitor (RC). (b) Crystal or ceramic 43 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. 2 15 ), 4) RC resistor capacitor 44
(a) Crystal or ceramic, HS, XT or LP. (b) Resistor capacitor. (c) Externally supplied clock 45 Data Sheet Information 46
Power Supply 100 nf decoupling capacitor RC Oscillator 47 16F84A operating conditions 48
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. 49 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. 50
Thanks,.. See you next week (ISA), ٥١