Lecture (03) PIC16F84 (2)

Similar documents
Lecture (04) PIC 16F84A programming I

PIC 16F84A programming (II)

DERTS Design Requirements (1): Microcontroller Architecture & Programming

Embedded Systems. PIC16F84A Internal Architecture. Eng. Anis Nazer First Semester

Lecture (02) PIC16F84 (I)

Model Answer Microcontrollers. MCQ Problems Total Q1 Q2

Computer Hardware Requirements for ERTSs: Microprocessors & Microcontrollers

Lecture (09) PIC16F84A LCD interface LCD. Dr. Ahmed M. ElShafee

PIC Microcontroller Introduction

EE 361L Digital Systems and Computer Design Laboratory

PIC16F87X. 28/40-pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features:

CHAPTER 1. Introduction to Microcontrollers. Introduction

CHAPTER 6 CONCLUSION AND SCOPE FOR FUTURE WORK

Q1 Q2 Q3 Q4 Q5 Q6 Total /7.5 /5 /10 /5 /7.5 /5 /40

Microcontroller Overview

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

Mechatronics and Measurement. Lecturer:Dung-An Wang Lecture 6

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

C and Embedded Systems. So Why Learn Assembly Language? C Compilation. PICC Lite C Compiler. PICC Lite C Optimization Results (Lab #13)

NH-67, TRICHY MAIN ROAD, PULIYUR, C.F , KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet... 4

Lecture (04) PIC16F84A (3)

University of Hawaii EE 361L MPLab Quick Tutorial and Project 2.1 Last updated September 1, 2011

MicroProcessor. MicroProcessor. MicroProcessor. MicroProcessor

ME 515 Mechatronics. A microprocessor

Hong Kong Institute of Vocational Education Digital Electronics & Microcontroller. 8. Microcontroller

Chapter 9. Input/Output (I/O) Ports and Interfacing. Updated: 3/13/12

Laboratory 10. Programming a PIC Microcontroller - Part II

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

n/a PIC12F629-I/P (RC) n/a PIC12F629-I/SN (RC) n/a PIC12F675-I/P (RC) n/a PIC12F675-I/SN MICROCONTROLLER (RC)

Explanation of PIC 16F84A processor data sheet Part 1: overview of the basics

The University of Texas at Arlington Lecture 5

Input/Output Ports and Interfacing

DEV-1 HamStack Development Board

8051 Microcontroller

which means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch.

Laboratory 9. Programming a PIC Microcontroller - Part I

ME 6405 Introduction to Mechatronics

SH69P48A EVB. Application Notes for SH69P48A EVB SH69V48A JP2 J4(ICE_J4) S1 IDD TEST JP1 74HC273 JP4 JP3 74HC273 JP6 STKOVE JP7 SW1 J5(ICE_J5)

Embedded Systems Design (630470) Lecture 4. Memory Organization. Prof. Kasim M. Al-Aubidy Computer Eng. Dept.

Section 8. Reset HIGHLIGHTS. Reset. This section of the manual contains the following major topics:

EasyPIC5 Development System

Section 30. In-Circuit Serial Programming (ICSP )

Embedded systems. Exercise session 3. Microcontroller Programming Lab Preparation

Section 28. WDT and SLEEP Mode

SH69P55A EVB. Application Note for SH69P55A EVB SH69P55A EVB SH69V55A

EEE3410 Microcontroller Applications Department of Electrical Engineering Lecture 4 The 8051 Architecture

Microcomputers. C and Embedded Systems

The Freescale MC908JL16 Microcontroller

PIC16C84. 8-bit CMOS EEPROM Microcontroller PIC16C84. Pin Diagram. High Performance RISC CPU Features: CMOS Technology: Peripheral Features:

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text

Section 8. Reset. Reset HIGHLIGHTS. This section of the manual contains the following topics:

Laboratory: Introduction to Mechatronics

3. The MC6802 MICROPROCESSOR

PIC16C52. EPROM-Based 8-Bit CMOS Microcontroller PIC16C52. Pin Diagrams. Feature Highlights. High-Performance RISC CPU. Peripheral Features

Introduction to Embedded Systems

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017

Outlines. PIC Programming in C and Assembly. Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University

Bolt 18F2550 System Hardware Manual

PIC16F8X. 8-Bit CMOS Flash/EEPROM Microcontrollers PIC16F8X PIC16CR8X. Pin Diagram. Devices Included in this Data Sheet:

Reprinted by permission of T&L Publications Inc. Copyright 2001 USB MICROCONTROLLERS FOR THE MASSES

PIC16F8X 18-pin Flash/EEPROM 8-Bit Microcontrollers

8051 Microcontroller Interrupts

SH69P25/P23/P20B EVB. Application Note for SH69P25/P23/P20B EVB SH69P25/P23/P20B EVB SH69V25

HT1621. RAM Mapping 32 4 LCD Controller for I/O µc. Features. General Description. Selection Table

Documentation Design File Formats

DESIGN AND FABRICATION OF FARE METER OF TAXICAB USING MICROCONTROLLER

PIC16F5X Data Sheet. Flash-Based, 8-Bit CMOS Microcontroller Series

Breeze Board. Type A. User Manual.

Embedded Systems Module. 6EJ505. C Tutorial 3: using the ICD3 rev tjw

Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices,

PIC16F84A. 18-pin Enhanced Flash/EEPROM 8-Bit Microcontroller. Devices Included in this Data Sheet: Pin Diagrams. High Performance RISC CPU Features:

Section 9. Watchdog Timer (WDT)

Laboratory Exercise 7 - Extended I/O & Parallel Processing

Computer Hardware Requirements for Real-Time Applications

SX Device In-System Programming Specifications

Renesas 78K/78K0R/RL78 Family In-Circuit Emulation

ATmega128. Introduction

M PIC16F84A. 18-pinEnhanced FLASH/EEPROM 8-Bit Microcontroller. High Performance RISC CPU Features: Pin Diagrams. Peripheral Features:

Timer1 Capture Mode:

UNISONIC TECHNOLOGIES CO., LTD 6621 Preliminary LINEAR INTEGRATED CIRCUIT

AKKON USB CONTROLLER BOARD

AN ELNEC EN ISP-HC08. Application note for In-System Programming of Motorola/Freescale HC08 microcontrollers

ENE 334 Microprocessors

Timer0..Timer3. Interrupt Description Input Conditions Enable Flag

ARM HOW-TO GUIDE Interfacing Switch with LPC2148 ARM

PIC16F5X Data Sheet. Flash-Based, 8-Bit CMOS Microcontrollers Microchip Technology Inc. Preliminary DS41213B

BME 4900 Page 1 of 2. Meeting 2: Personal Progress Report 12/2/09 Team 12 with Drew Seils. Semester One Week Two

NTE1731 Integrated Circuit CMOS 10 Number Pulse Dialer

Architecture of Computers and Parallel Systems Part 6: Microcomputers

University of Dayton. Electrical & Computer Engineering. ECE 536 Microprocessor Applications. Dr. Ralph Barrera. Assignment (4)

MC68HC05J1A/D Rev. 1.0 HC 5 MC68HC05J1A MC68HCL05J1A MC68HSC05J1A. HCMOS Microcontroller Units TECHNICAL DATA

Chapter 2 Sections 1 8 Dr. Iyad Jafar

PIC16F5X Data Sheet. Flash-Based, 8-Bit CMOS Microcontroller Series Microchip Technology Inc. DS41213D

Section 11. Timer0. Timer0 HIGHLIGHTS. This section of the manual contains the following major topics:

Embedded Systems Lab Lab 1 Introduction to Microcontrollers Eng. Dalia A. Awad

Flow Charts and Assembler Programs

SH69P21 EVB. Application Note for SH69P21 EVB SH69P21 EVB SH69P21

CHAPTER 1 - World of microcontrollers

PC3 PC4 PC5 PC6 PC7 VSS VPP1 PB0 PB1 PB2 PB3 PB4 PB5

Transcription:

Lecture (03) PIC16F84 (2) By: Dr. Ahmed ElShafee ١ PIC16F84 has a RISC architecture, or Harvard architecture in another word ٢

PIC16F84 belongs to a class of 8 bit microcontrollers of RISC architecture. Program memory (FLASH) for storing a written program. can be programmed and cleared more than once. EEPROM data memory that needs to be saved when there is no supply. ٣ RAM data memory used by a program during its execution. In RAM are stored all inter results or temporary data during run time. PORTA and PORTB are physical connections between the microcontroller and the outside world. Port A has five, and port B has ٤ eight pins.

FREE RUN TIMER is an 8 bit register inside a microcontroller that works independently of the program. On every fourth clock of the oscillator it increments its value until it reaches the maximum (255), and then it starts counting over again from zero. As we know the exact timing between each two increments of the timer contents, timer can be used for measuring time. CENTRAL PROCESSING UNIT has a role of connective element between other blocks in the microcontroller. It coordinates the work of other blocks and executes the user program. ٥ Clock / instruction cycle Clock from the oscillator enters a microcontroller via OSC1 pin where internal circuit of a microcontroller divides the clock into four even clocks Q1, Q2, Q3, and Q4 which do not overlap ٦

These four clocks make up one instruction cycle (also called machine cycle) during which one instruction is executed Q1 : fetching current instruction according to PC (program counter) Q2: encoding current instruction Q3 executing the previous instruction (which saved in instruction register from previous cycle) Q4 writing current instruction to instruction register ٧ If instruction causes a change on program counter, and PC doesn't point to the following but to some other address two cycles are needed for executing the correct instruction in the new locatop This is so because instruction must be processed again, but this time from the right address. ٨

Instructions set 16F84 precisely 35 instructions. (ex. Intel's and Motorola's microcontrollers have over hundred instructions) All of these instructions are executed in one cycle except for jump and branch instructions. PIC16F84 usually reaches results of 2:1 in code compression and 4:1 in speed in relation to other 8 bit microcontrollers in its class. ٩ Pin description PIC16F84 has a total of 18 pins (DIP18 ) (Dual In Package) or (SMD 18) (Surface Mount Devices). Pin no.1 RA2 Second pin on port A. Has no additional function Pin no.2 RA3 Third pin on port A. Has no additional function. Pin no.3 RA4 Fourth pin on port A. TOCK1 which functions as a timer is also found on this pin Pin no.4 MCLR Reset input and Vpp programming voltage of a microcontroller Pin no.5 Vss Ground of power supply. Pin no.6 RB0 Zero pin on port B. Interrupt input is an additional function. ١٠

Pin no.7 RB1 First pin on port B. No additional function. Pin no.8 RB2 Second pin on port B. No additional function. Pin no.9 RB3 Third pin on port B. No additional function. Pin no.10 RB4 Fourth pin on port B. No additional function. Pin no.11 RB5 Fifth pin on port B. No additional function. Pin no.12 RB6 Sixth pin on port B. 'Clock' line in program mode. Pin no.13 RB7 Seventh pin on port B. 'Data' line in program mode. Pin no.14 Vdd Positive power supply pole. Pin no.15 OSC2 Pin assigned for connecting with an oscillator Pin no.16 OSC1 Pin assigned for connecting with an oscillator Pin no.17 RA2 Second pin on port A. No additional function Pin no.18 RA1 First pin on port A. No additional function. ١١ Clock generator oscillator Oscillator circuit is used for providing a microcontroller with a clock. Clock is needed so that microcontroller could execute a program or program instructions PIC16F84 can work with four different configurations of an oscillator, two of them are crystal oscillator resistor capacitor (RC) ١٢

XT Oscillator Crystal oscillator is kept in metal housing with two pins, the operating frequency is written on housing. A 33pf ceramic capacitors are connected to gnd. Oscillator and capacitors can be packed in joint case with three pins, called ceramic resonator ١٣ RC Oscillator Resonant frequency of RC oscillator depends on supply voltage rate, resistance R, capacity C and working temperature. R value should be greater than 2.2K and less than 1M to avoid unstability Recommended R is between 3K and 100k capacitor should be above 20pF ١٤

Oscillator clock divided by 4 can also be obtained on OSC2/CLKOUT pin, and can be used for testing or synchronizing other logical circuits Following a supply, oscillator starts oscillating. Oscillation at first has an unstable period and amplitude, but after some period of time it becomes stabilized ١٥ To prevent such inaccurate clock from influencing microcontroller's performance, we need to keep the microcontroller in reset state during stabilization of oscillator's clock. ١٦

Reset Reset is used when microcontroller doesn't behave the way we want it to, interrupt in program execution, to get a microcontroller ready when loading a program. MCLR has to be connected via resistor to the positive supply pole, to prevent from bringing a logical zero to MCLR pin ١٧ sources of resets: Reset during power on, POR (Power On Reset) Reset during regular work by bringing logical zero to MCLR microcontroller's pin. Reset during SLEEP regime Reset at watchdog timer (WDT) overflow Reset during at WDT overflow during SLEEP work regime. During a reset, RAM memory locations are not being reset. They are unknown during a power up and are not changed at any reset. SFR registers are reset to a starting position initial state.setting a program counter (PC) to zero (0000h) ١٨

Brown out Reset Impulse for resetting is generated by microcontroller itself when supply doesn't drop to zero but falls below the limit that guarantees microcontroller's proper functioning (in a range from 1.2V to 1.8V) ١٩ That impulse lasts 72ms which is enough time for an oscillator to get stabilized. These 72ms are provided by an internal PWRT timer which has its own RC oscillator. ٢٠

Ports refers to a group of pins on a microcontroller which can be accessed simultaneously, or on which we can set the desired combination of zeros and ones, or read from them an existing status. Physically, port is a register inside a microcontroller which is connected by wires to the pins of a microcontroller. some pins have twofold roles like PA4/TOCKI, fourth bit of port A and an external input for free run counter. ٢١ Selection of one of these two pin functions is done in one of the configuration registers In order to define a pin as input or output pin, the right combination of zeros and ones must be written in TRIS register. logical "1", then that pin is an input pin logical 0", then that pin is an output pin port A has TRISA, and port B has TRISB Pin direction can be changed during your program PORTA and PORTB state registers are located in bank 0, while TRISA and TRISB pin direction registers are located in bank 1 ٢٢

PORTB and TRISB Setting a bit in TRISB register defines the corresponding port pin as input, and resetting a bit in TRISB register defines the corresponding port pin as output. ٢٣ Each PORTB pin has a weak internal pull up resistor (resistor which defines a line to logic one) These 'pull up' resistors are automatically being turned off when port pin is configured as an output. When a microcontroller is started, pull ups are disabled. ٢٤

PORTA and TRISA PORTA has 5 adjoining pins. The corresponding register for data direction is TRISA Note: RA4 can be input only ٢٥ Writing a specialized program in a PC called compiler is in charge of compiling program into machine language. Unlike assembly compilers, these create an executable code which is not always the ٢٦ shortest possible.

Here is an example of a simple program written in C language: ٢٧ the higher programming languages, such as C, are concerned because somebody has already solved this and many other similar problems for you. It will do to ٢٨ write a*b.

The main idea of writing program in C language is to break a bigger problem down into several smaller pieces. To write a program for the microcontroller that is going to measure temperature and show results on an LCD display. 1. Activate and set built in A/D converter; 2. Measure analogue value; 3. Calculate temperature; and 4. Send data in the proper form to LCD ٢٩ display Creating project ٣٠

٣١ ٣٢

٣٣ ٣٤

٣٥ ٣٦

٣٧ ٣٨

When programming MC, you need to set configuration word manually ٣٩ LedFlasher #include <xc.h> #include <pic16f84a.h> int main(void) { TRISB=0x00; while(1) { } } PORTB=0xff; _delay(100000); PORTB=0x00; _delay(100000); return (0); ٤٠

Working with simulator ٤١ ٤٢

٤٣ ٤٤

٤٥ ٤٦

٤٧ ٤٨

٤٩ ٥٠

٥١ PressControllerdFlasher #include <xc.h> #include <pic16f84a.h> int main(void) { TRISB=0x00; TRISA=0xff; while(1) { if(ra0==0) { PORTB=0xff; _delay(100000); PORTB=0x00; _delay(100000); } ٥٢

else { } PORTB=0x00; } } return (0); ٥٣ ٥٤

PressControlledLedStatusToggleC #include <xc.h> #include <pic16f84a.h> ٥٥ int main(void) { int led_status=0; TRISB=0x00; TRISA=0xff; PORTB=0x00; while(1) { if(ra0==0) { _delay(10000); if(led_status==0){led_status=1;} else if(led_status==1){led_status=0;} } if(led_status==0) PORTB=0x00; else if(led_status==1) PORTB=0xff; _delay(100000); } } return (0); ٥٦

LedChaserC #include <xc.h> #include <pic16f84a.h> int main(void) { unsigned char ch=0x01; TRISB=0x00; while(1) { _delay(100000); if(ch==0x00)ch=0x01; else ch=ch*2; PORTB=ch; } return (0); } ٥٧ ٥٨

Thanks,.. See you next week (ISA), ٥٩