Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.

Slides:



Advertisements
Similar presentations
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
Advertisements

Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
INSTRUCTION SET ARCHITECTURES
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
POWER ELECTRONICS Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical Engineering Department بسم الله.
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2013 Lecture 26: PIC microcontroller intro.
16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 30: PIC data memory.
Microcontroller Architecture— PIC18F Family
Railway Foundation Electronic, Electrical and Processor Engineering.
Microprocessor and Microcontroller Based Systems
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
The MSP430xxxx Department of Electrical and Computer Engineering
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
Lecture – 5 Assembly Language Programming
Parul Polytechnic Institute Parul Polytechnic Institute Subject Code : Name Of Subject : Microprocessor and assembly language programming Name.
Chapter 4 Starting to Program – an Introduction to Assembler The aims of this chapter are to introduce: the essentials of Assembler programming; the Microchip.
Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.
Building Assembler Programs Chapter Five Dr. Gheith Abandah1.
A Simple Tour of the MSP430. Light LEDs in C LEDs can be connected in two standard ways. Active high circuit, the LED illuminates if the pin is driven.
Parallel Ports, Power Supply and the Clock Oscillator Material to be covered  Parallel I/O ports  Interfacing external switches and LEDs  Clock Oscillator.
Directives, Memory, and Stack. Directives Special commands to the assembler May or may not generate machine code Categories by their function Programming.
The 8051 Microcontroller and Embedded Systems
Lecture – 4 PIC18 Family Instruction Set 1. Outline Literal instructions. Bit-oriented instructions. Byte-oriented instructions. Program control instructions.
Chapter 2 Introducing the PIC Mid-Range Family and the 16F84A The aims of this chapter are to introduce: The PIC mid-range family, in overview The overall.
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
Embedded System Spring, 2011 Lecture 11: Bank Switching Eng. Wazen M. Shbair.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
Today’s Lecture Unconditional branch instruction
EEE237 Introduction to Microprocessors Week x. SFRs.
Eng. Husam Alzaq The Islamic Uni. Of Gaza
Architecture and instruction set. Microcontroller Core Features:  Operating speed: DC - 20 MHz clock input DC ns instruction cycle Up to 8K x.
POWER ELECTRONICS Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical Engineering Department بسم الله.
Department of Electronic & Electrical Engineering Template program. Input / Output (IO) ● Template program. ● Introduction to IO ● Setting up for IO ●
Department of Electronic & Electrical Engineering Lecture 2 ● Introduction to IO ● Using a subroutine ● Driving a 7seg display.
Department of Electronic & Electrical Engineering Lecture 2. PIC16F84A Architecture / Instructions Memory. Program/Data (Harvard) File Registers (Data).
بسم الله الرحمن الرحيم MEMORY AND I/O.
Working with Time: Interrupts, Counters and Timers
Embedded System Spring, 2011 Lecture 11: Bank Switching Eng. Wazen M. Shbair.
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
Chapter 5 Building Assembler Programs The aims of this chapter are to introduce: how to visualise a program, and represent it diagrammatically; how to.
Department of Electronic & Electrical Engineering Lecture 4. ➢ Loops ➢ Delays ➢ Conditional instructions ➢ Simple clock example.
Department of Electronic & Electrical Engineering Lecture 3. ● Template program. ● Introduction to IO ● PORTA PORTB TRISA TRISB ● Using a subroutine ●
Programming PIC 16F84A in Assembly. PIC16F84 pin-out and required external components.
Dr. Iyad Jafar Introducing the PIC 16 Series and the 16F84A.
Instructor: Eng.Moayed N. EL Mobaied
Basic Computer Organization and Design
Lecture – 5 Assembly Language Programming
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor T. Y. B. Sc..
Memory Organisation Source: under
Microprocessor Systems Design I
Microprocessor Systems Design I
16.317: Microprocessor System Design I
Microprocessor Systems Design I
Microcomputer Programming
Introducing the PIC Mid-Range Family and the 16F84A
Memory Organisation Source: under
Chapter 4 Instruction Set.
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
INSTRUCTION SET.
EECE.3170 Microprocessor Systems Design I
Memory Organisation Source: under
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
Presentation transcript:

Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical Engineering Department بسم الله الرحمن الرحيم EELE 4315 — Fall 2010 Lecture 8

Initial Program Design – Flow Diagram (chart)

An Alternative Program Visualisation - State Diagrams

Conditional Branching One of the most important features of any microprocessor or microcontroller program is its ability to make “decisions”, i.e. to act differently according to the state of logical variables. Many microprocessors have within their instruction sets a number of instructions which allow them to test a particular bit, and either continue program execution if the condition is not met, or branch to another part of the program if it is. Often these variables are bit values in the Status Registers. The PIC 16 Series microcontrollers have four conditional “skip” instructions. These test for a certain condition, and skip just one instruction if the condition is met, and continue normal program execution if it is not. The most versatile and general-purpose of these are: btfscf,b btfssf,b

Testing and Manipulating Single Bits ;The “main” program starts here movlw 00;clear all bits in port A and B movwf porta movwf portb loopbcfportb, 3;preclear port B, bit 3 btfss porta, 3 bsfportb, 3;but set it if button pressed ; bcfportb, 4;preclear port B, bit 4 btfss porta, 4 bsfportb, 4;but set it if button pressed gotoloop end

Subroutines The subroutine is a program section structured in such a way that it can be called from anywhere in the program. Once it has been executed the program continues to execute from wherever it was before. The PIC 16 Series subroutine call and return instructions are call and return.. Subroutine Call and Return instructions must always work in pairs.

A Subroutine Example: Software Time Delays As long as the microcontroller is driven by a stable clock oscillator, we know precisely how long any instruction takes to execute. We can therefore write time delays of very high accuracy.

A Subroutine Example: Software Time Delays ;Delay of 5ms approx. Instruction cycle time is 5us. delay5 movlw D'200' ;200 cycles called, each taking 5x5=25us movwf delcntr1 del1 nop;1 inst. cycle nop;1 inst. cycle decfsz delcntr1,1;1 inst. cycle, when no skip goto del1;2 inst. cycles return A Delay Subroutine ;500ms delay (approx);100 calls to delay5 delay500 movlw D'100' movwf delcntr2 del2 call delay5 decfsz delcntr2,1 goto del2 return Nested Subroutines for Greater Delay

Time calculation Instruction MOVLW.10 take one cycle and instruction MOVWF take one cycle. Instruction DECFSZ take one cycle when escape don’t make but it take 2cycle when escape is made,so it repeat 9 times as one cycle and take two cycles for one time. NOP take one cycle but it repeat 10 times. GOTO take 2cycle but it repeat 9 time,

Time calculation

Where Tc is the time of cycle in seconds.

Time calculation Where Tc is the time of cycle in seconds.

Time calculation Where Tc is the time of cycle in seconds.

OPCODE The PIC 16 Series has four possible instruction word formats, The instruction word is made up of 14 bits. These appear as bits 0 to 13. The opcode, the actual instruction part of the instruction word, always occupies the highest bits of the instruction word. f (Register file) : f can specify an address from 0(00h) to 127(7Fh) because it is 7 bits. In case of PIC16F84A, because the register memory is 80 bytes including SFR, it is possible to be specified by f if being 7 bits.

ADDRESSING MODES RAM memory locations can be accessed directly or indirectly. Direct Addressing is done through a 9-bit address. This address is obtained by connecting 7th bit of direct address of an instruction with two bits (RP1, RP0) from STATUS register

Direct Addressing mode

Any access to SFR registers can be an example of direct addressing.

indirect Addressing mode It does not take an address from an instruction, but it derives it from IRP bit of STATUS and FSR registers. Addressed location is accessed through INDF register which in fact holds the address indicated by the FSR. Indirect addressing is very convenient for manipulating data arrays located in GPR registers. In this case, it is necessary to initialize FSR register with a starting address of the array, and the rest of the data can be accessed by incrementing the FSR register.

Example for indirect addressing

Configuration register The configuration bits can be programmed (read as '0'),or left un programmed (read as '1'), to select various device configurations. These bits are mapped in program memory location 2007h. Address 2007h is beyond the user program memory space and it belongs to the special test/configuration memory space (2000h - 3FFFh). This space can only be accessed during programming.