Applications examples. A binary count : stepped manually and reset with push buttons. Define ports Reset portd Reset =0? INCF portd no Step =0? yes.

Slides:



Advertisements
Similar presentations
振動スイッチを活用 振動(傾き)を検出 ボールが移動 a)オン時 b)オフ時 オンからオフ時の観察.
Advertisements

Control structures Hot to translate high level control structures to assembler.
Electronics Design Lab TUTORIAL PIC Microcontrollers Francesco Tenore 2/10/2006.
Input/Output Ports and Interfacing ELEC 330 Digital Systems Engineering Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning.
Prof. Jorge A. Ramón Introducción a Microcontroladores.
The human and physical interfaces Chapter Eight 8.1 – 8.9 Dr. Gheith Abandah1.
SENIOR PROJECT PRESENTATION REMOTE CONTROL CAR MURAT DİNÇER.

Chapter 4 Starting to Program – an Introduction to Assembler The aims of this chapter are to introduce: the essentials of Assembler programming; the Microchip.
Microcontroller Programming How to make something almost do something else Raffi Krikorian MAS November 2003.
Two’s Complement Number wheel for 4 bit numbers
1 4-Integrating Peripherals in Embedded Systems (cont.)
Building Assembler Programs Chapter Five Dr. Gheith Abandah1.
Input/Output Ports and Interfacing
I/O PORTS (Simplest Peripherals) PORT A: 6 bits wide (7th and 8th bit always read as 0) PORT B: 8 bits wide PORT C: 8 bits wide PORT D: 8 bits wide.
Microprocessor and Interfacing PIC Code Execution
George Mason University ECE 448 – FPGA and ASIC Design with VHDL Experiment 7 VHDL Modeling of Embedded Microprocessors and Microcontrollers.
 Mini-Computer  Microprocessor  The Brains  Arithmetic Logic Unit (ALU)  Control Unit  Program/ Data Storage  Peripherals (Input/Output) Low-Cost.
EEE237 Introduction to Microprocessors Week x. SFRs.
Architecture and instruction set. Microcontroller Core Features:  Operating speed: DC - 20 MHz clock input DC ns instruction cycle Up to 8K x.
Training program: Mechanic - electrotechnician Program name: Digital processing - microprocessors III. class Microcontrollers Elaborated by: Vlastimil.
PIC Code Execution How does the CPU executes this simple program? void main() { int i; i = 1; i++; }
Department of Electronic & Electrical Engineering Seven segment display Subroutines.
Department of Electronic & Electrical Engineering Lecture 2 ● Introduction to IO ● Using a subroutine ● Driving a 7seg display.
Working with Time: Interrupts, Counters and Timers
PIC16F887.
4) Design the logic to control the motor on a simple remote control car. There are two buttons on the remote control for the motor. If neither button is.
PIC12F629/675. “Wide variety” 8-84 pin RISC core, 12/14/16bit program word USART/AUSART, I 2 C, ADC, ICSP, ICD OTP/UV EPROM/FLASH/ROM Families: PIC12,
Microcontrollers A Practical Approach Ernesto Arroyo
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.
I/O PORTS. General purpose I/O pins can be considered the simplest of peripherals. They allow the PICmicro™ to monitor and control other devices. To add.
Microprocessor Systems Design I
Chapter 9 PIC18 Timer Programming in Assembly
Microprocessor Systems Design I
Microprocessor Systems Design I
4-Integrating Peripherals in Embedded Systems (cont.)
Prof. Ahmad Abu-El-Haija
Microprocessor Systems Design I
Microprocessor Systems Design I
Microprocessor Systems Design I
Micro-processor vs. Micro-controller
Microprocessor Systems Design I
C. K. PITHAWALA COLLEGE OF ENGINEERING AND TECHNOLOGY
INT. TO EMBEDDED SYSTEMS DEVELOPMENT
Microprocessor Systems Design I
Microprocessor Systems Design I
PIC 16F877.
16.317: Microprocessor System Design I
EECE.3170 Microprocessor Systems Design I
Projekt Anglicky v odborných předmětech, CZ.1.07/1.3.09/
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
INSTRUCTION SET.
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
Lab 1. Introduction to the DE2 Board
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
Interface ckt for demo Outputs Inputs V PIN 0 10K PIN 4 GND GND
PIC18 Interrupt Programming
Presentation transcript:

Applications examples

A binary count : stepped manually and reset with push buttons. Define ports Reset portd Reset =0? INCF portd no Step =0? yes

BTFSC PORTB,2 GOTO START CLRW MOVWFTRISD MOVLW0X06 MOVWFTRISB RESET :CLRF PORTD INCF portd GOTO START START:BTFSS PORTB,1 GOTO RESET Define ports Reset portd RB1 =0? INCF portd no RB2 =0? yes Code for stepped manually binary count

Simple home security system Switches are active high; The system works only when ARMED If AWAY is set :all sources of alarms are checked If AWAY is reset: only alarms door & window are checked When the alarm is set on, the system waits for some one to disarm the system

Define ports Reset alarm Armed? no Away? no zone1? no zone2? no window? no door? no y y set alarm Armed? y n yes Code for home security

START BCF PORTC,0 AGAIN BTFSS PORTB, ARMED; system is armed GOTO AGAIN; BTFSS PORTB, AWAY; no people at home GOTO HOME; people are at home BTFSC PORTD, ZONE1; if no alarm from zone1 GOTO ALARM BTFSC PORTD, ZONE2; if no alarm from zone2 GOTO ALARM HOME BTFSC PORTD, WINDOW; if no alarm from window GOTO ALARM BTFSC PORTD, FRONTDOOR; if no alarm from door GOTO ALARM GOTO AGAIN; if no alarm from any where ALARM BSF PORTC,1 DISABLE_ALARM BTFSC PORTB, ARMED GOTO DISABLE_ALARM GOTO START END Define ports Reset alarm Armed? no Away? no zone1? no zone2? no windo w? no door? no y y set alarm Armed? y n

The seven segment display : the "step" botton increments the count on the seven segment display ( 0-F) ;the "reset" resets the count Display digit 0 Is “reset “ =1? Is “step “ =1? Initialize ports Increment the Display Y N

count on the seven segment display ( 0-F) -2 Display digit 0 Is “reset “ =1? Is “step “ =1? Initialize ports Increment the Display Y N CLRW MOVWF TRISC BSFTRISD,0 BSFTRISD,1 WAIT MOVLW 0x3F; MOVWFPORTC GOTO main Main BTFSC PORTD, 1 GOTO WAIT Loop1:BTFSS PORTD, 0; GOTO loop1; INCFCNT,1; MovfCNT,0; ANDLW0X0F; CALLshow Table: ADDWFPCL RETLWB' ' RETLWB' ' RETLWB' ' RETLWB' ' RETLWB' ‘ RETLWB' ' RETLWB' ' RETLWB' ' RETLWB' ' RETLWB' ' RETLWB' ' RETLWB' ' RETLWB' ' RETLWB' ' RETLWB' ' RETLWB' ' Show: CALLtable MOVWFPORTC RETURN

Keypads 1.an array of push buttons connected in rows and columns. 2.each can be tested for closure inputs outputs

Keypad connection inputs outputs Initially set high

The main program will do the following: 1.set RD4-RD7 high 2.Call scan 3.Call show 4.Loop. main MOVLW 0xFF MOVWF PORTD CALL scan CALL show GOTO main END Write a program that display’s the pressed key on the 7-segment

Scan Key=0:cy=1 RD0=0? RD1=0? RD2=0? y RD4=0 INCR KEY RET RD3=1 CY=0? RL PORTD Re-start scanning new row row INCF Key BTFSS PORTD,0 GOTO found INCF Key BTFSS PORTD,1 GOTO found INCF Key BTFSS PORTD,2 GOTO found GOTO next scan CLRF Key BSF 3,0 BCF PORTD,4 newrow GOTO row next BSF PORTD,3 RLF PORTD BTFSC 3,0 GOTO newrow GOTO scan found RETURN next Found y y y

Keypad program: the show subroutine show CALL table MOVWF PORTC RETURN table MOVF Key,W ADDWF PCL NOP RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' Code for 1

Keypad program row INCF Key BTFSS PORTD,0 GOTO found INCF Key BTFSS PORTD,1 GOTO found INCF Key BTFSS PORTD,2 GOTO found GOTO next table MOVF Key,W ADDWF PCL NOP RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' RETLW B' ' scan CLRF Key BSF 3,0 BCF PORTD,4 newrow GOTO row next BSF PORTD,3 RLF PORTD BTFSC 3,0 GOTO newrow GOTO scan found RETURN main MOVLW 0FF MOVWF PORTD CALL scan CALL show GOTO main END show CALL table MOVWF PORTC RETURN

TRAFFIC LIGHTS Turn on green on light1: red on light 2 Wait 15 sec on the display Turn on green and yellow on light1: red on light 2 Wait 5 sec on the display Turn on green on light2: red on light1 Wait 15 sec on the display Turn on green and yellow on light2: red on light 1 Wait 5 sec on the display