Anda di halaman 1dari 34

UFME69-20-2 Micro-controller Based System

INTRODUCTION The purpose of this Drinks Vending Machine Controller with using Bitproc trainer module is

University of the West of England

Page 1

UFME69-20-2 Micro-controller Based System

Full schematic diagram

University of the West of England

Page 2

UFME69-20-2 Micro-controller Based System

Voltage Regulator Figure 1 below is Voltage regulator that design to reduce the voltage signal to the lower voltage required by the circuit.

Figure 1

Voltage Regulator Calculation

Vout = 1.25V x (1 + R2 / R1) + Iadj (R2) = 1.25V x (1 + 390 / 150) = 1.25V x 3.6 = 4.5V

So R1 = 150,

R2 = 390

University of the West of England

Page 3

UFME69-20-2 Micro-controller Based System

PIC18F14K22

Figure 2 The Figure 2 above is describe about the PIC18F14K22 with the connection to accelerometer and LCD display. All device in this PIC family incorporate a range of features that can significantly reduce power consumption during operation. This PIC have several advantages and it is are high computational performance with the addition of high-endurance, Flash program memory. Diode zener is used to breaks down at a very specific reverse-bias voltage and because of that, diode zener can be used to regulate the voltage in a circuit.

Figure 3 The Figure 3 above is a MMA8452Q Accelerometer that is smart low-power, three-axis, capacitive micro machined accelerometer with 12 bits of resolution. This accelerometer is packed with embedded function with flexible user programmable options, configure to two interrupt pins. Embedded interrupt functions allow for overall power savings relieving the host processor from continuously polling data. The device can be configured

University of the West of England

Page 4

UFME69-20-2 Micro-controller Based System

to generate inertial wakeup interrupt signals from any combination of the configurable embedded function allowing the MMA8452Q to monitor events and remain in a low power mode during periods of inactivity.

LCD Display module

Figure 4 The Figure 4 above is the LCD Display module is a LSI controller that has two 8-bit registers, an instruction register (IR) and a data register (DR). The IR stores instruction codes, such as display clear and cursor shift, and address information for display data RAM (DDRAM) and character generator (CGRAM). The DR temporarily stores data to be written or read from DDRAM or CGRAM.

So this picture is my hardware of Hello World! Display on LCD module that I have been build.

University of the West of England

Page 5

UFME69-20-2 Micro-controller Based System

Software Flowcharts Task 1

University of the West of England

Page 6

UFME69-20-2 Micro-controller Based System

Task 2

University of the West of England

Page 7

UFME69-20-2 Micro-controller Based System

Task 3

University of the West of England

Page 8

UFME69-20-2 Micro-controller Based System

Task 1 ;***************************************************************************************** ;Written by : Noor Hasanah Mohd Nazri ;Date : 14/01/2012 ;Version : ;File saved as : Hello World1 ;For PIC : 18F14K22 ;***************************************************************************************** ;Program Function : LCD module displays "Hello World!" on power-up ;***************************************************************************************** include "P18F14K22.INC" ;This tells the assembler to include ;another source file Delayreg EQU H'21' Delayreg2 EQU H'22' ;======================================================================== banksel clrf clrf clrf clrf clrf banksel TRISA TRISA TRISB TRISC PORTB PORTC PORTA ;change register bank or page 1

;make PORTB an output port ;make PORTC an output port ;change back to original bank/page 0

;======================================================================== start clrf PORTB ; clrf PORTC ; call Delay_40ms ; ;======================================================================== _configLCD bcf PORTA,4 ; bcf PORTB,7 ; movlw b'00111100' ; movwf PORTC ; bsf PORTA,5 ; bcf PORTA,5 ; call Delay_37us ; movlw movwf b'00111000' PORTC ; ; Page 9

University of the West of England

UFME69-20-2 Micro-controller Based System

bsf bcf call movlw movwf bsf bcf call movlw movwf bsf bcf call movlw movwf bsf bcf call

PORTA,5 PORTA,5 Delay_37us b'00001110' PORTC PORTA,5 PORTA,5 Delay_37us b'00000001' PORTC PORTA,5 PORTA,5 Delay_37us b'00000110' PORTC PORTA,5 PORTA,5 Delay_40ms

; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ;

;======================================================================== output bsf PORTB,7 ; movlw 'H' ; movwf PORTC ; bsf PORTA,5 ; bcf PORTA,5 ; call Delay_37us ; bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf PORTB,7 PORTA,4 'e' PORTC PORTA,5 PORTA,5 Delay_37us PORTB,7 PORTA,4 'l' PORTC PORTA,5 ; RS must be high to send letter in ; Clear RW pin ; Move letter 'e' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter 'l' into W register ; Send data to PORTC ; Setting and clearing A5 to clock Page 10

University of the West of England

UFME69-20-2 Micro-controller Based System

bcf call bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call bcf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call bsf

PORTA,5 Delay_37us PORTB,7 PORTA,4 'l' PORTC PORTA,5 PORTA,5 Delay_37us PORTB,7 PORTA,4 'o' PORTC PORTA,5 PORTA,5 Delay_37us PORTB,7 PORTA,4 b'11000000' PORTC PORTA,5 PORTA,5 Delay_40ms PORTB,7 PORTA,4 'W' PORTC PORTA,5 PORTA,5 Delay_37us PORTB,7 PORTA,4 'o' PORTC PORTA,5 PORTA,5 Delay_37us PORTB,7

; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter 'l' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter 'o' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; Clear RS pin ; Clear RW pin ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter 'W' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter 'o' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; Clear RW pin Page 11

University of the West of England

UFME69-20-2 Micro-controller Based System

bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call sleep

PORTA,4 'r' PORTC PORTA,5 PORTA,5 Delay_37us PORTB,7 PORTA,4 'l' PORTC PORTA,5 PORTA,5 Delay_37us PORTB,7 PORTA,4 'd' PORTC PORTA,5 PORTA,5 Delay_37us PORTB,7 PORTA,4 '!' PORTC PORTA,5 PORTA,5 Delay_37us

; Clear RW pin ; Move letter 'r' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter 'l' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter 'd' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter '!' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ;

;************************************************************************************* Delay_37us movlw 0x07 movwf Delayreg Delay_loop decfsz Delayreg goto Delay_loop return ;======================================================================== Delay_40ms movlw 0x1F University of the West of England Page 12

UFME69-20-2 Micro-controller Based System

movwf outer movlw movwf routene decfsz goto decfsz goto return End

Delayreg

0x03 Delayreg2

Delayreg2 routene Delayreg outer

; This tells the assembler this is all

University of the West of England

Page 13

UFME69-20-2 Micro-controller Based System

Task 2 ;************************************************************************* ;Written by : Noor Hasanah Mohd Nazri ;Date : 14/01/2012 ;Version : ;File saved as : Hello World1 ;For PIC : 18F14K22 ;************************************************************************* ;Program Function : LCD module displays "Hello World!" ;************************************************************************* include "P18F14K22.INC" ;This tells the assembler to include ;another source file Delayreg EQU H'21' Delayreg2 EQU H'22' Delayreg3 EQU H'23' ;========================================================================== banksel clrf clrf clrf clrf clrf banksel TRISA TRISA TRISB TRISC PORTB PORTC PORTA ;change register bank or page 1

;make PORTB an output port ;make PORTC an output port ;change back to original bank/page 0

;=========================================================================== start clrf PORTB ; clrf PORTC ; call Delay_40ms ; ;=========================================================================== _configLCD bcf PORTA,4 ; bcf PORTB,7 ; movlw b'00111100' ; movwf PORTC ; bsf PORTA,5 ; bcf PORTA,5 ; call Delay_37us ;

University of the West of England

Page 14

UFME69-20-2 Micro-controller Based System

movlw movwf bsf bcf call

b'00111000' PORTC PORTA,5 PORTA,5 Delay_37us

; ; ; ; ;

movlw movwf bsf bcf call

b'00001110' PORTC PORTA,5 PORTA,5 Delay_37us

; ; ; ; ;

movlw movwf bsf bcf call

b'00000001' PORTC PORTA,5 PORTA,5 Delay_37us

; ; ; ; ;

movlw movwf bsf bcf call

b'00000110' PORTC PORTA,5 PORTA,5 Delay_40ms

; ; ; ; ;

;=========================================================================== output bcf movlw movwf bsf bcf call bsf movlw movwf bsf bcf call PORTB,7 b'00000001' PORTC PORTA,5 PORTA,5 Delay_40ms PORTB,7 'H' PORTC PORTA,5 PORTA,5 Delay ; ; ; ; ; ; ; ; ; ; ; ;

University of the West of England

Page 15

UFME69-20-2 Micro-controller Based System

bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call bcf bcf movlw movwf bsf bcf call bsf bcf movlw movwf

PORTB,7 PORTA,4 'e' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 'l' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 'l' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 'o' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 b'11000000' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 'W' PORTC

; RS must be high to send letter in ; Clear RW pin ; Move letter 'e' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter 'l' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter 'l' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter 'o' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; Clear RW pin ; Clear RW pin ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter 'W' into W register ; Send data to PORTC Page 16

University of the West of England

UFME69-20-2 Micro-controller Based System

bsf bcf call bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call

PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 'o' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 'r' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 'l' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 'd' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 '!' PORTC PORTA,5 PORTA,5 Delay

; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter 'o' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter 'r' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter 'l' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter 'd' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; RS must be high to send letter in ; Clear RW pin ; Move letter '!' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ;

University of the West of England

Page 17

UFME69-20-2 Micro-controller Based System

goto output ;=============================================================================== Delay_37us movlw movwf Delay_loop decfsz goto return Delayreg Delay_loop 0x07 Delayreg

;=============================================================================== Delay_40ms movlw movwf Delay401 movlw movwf Delay40loop decfsz goto decfsz goto return ;=============================================================================== Delay movlw movwf Delay_A movlw movwf Delay_B movlw movwf 0x07 Delayreg3 Page 18 0x0F Delayreg2 0xFF Delayreg Delayreg2 Delay40loop Delayreg Delay401 0xFF Delayreg2 0x1F Delayreg

University of the West of England

UFME69-20-2 Micro-controller Based System

loop1 decfsz goto decfsz goto decfsz goto return outer movlw movwf routene decfsz goto decfsz goto return End Delayreg2 routene Delayreg outer 0x03 Delayreg2 Delayreg3 loop1 Delayreg2 Delay_B Delayreg Delay_A

; This tells the assembler this is all

University of the West of England

Page 19

UFME69-20-2 Micro-controller Based System

Task 3 ;************************************************************************* ;Written by : Noor Hasanah Mohd Nazri ;Date : 14/01/2012 ;Version : ;File saved as : Hello World ;For PIC : 18F14K22 ;************************************************************************* ;Program Function : LCD module displays "Hello World!" ;************************************************************************* include "P18F14K22.INC" ;This tells the assembler to include ;another source file Delayreg EQU H'21' Delayreg2 EQU H'22' Delayreg3 EQU H'23' ;========================================================================== banksel TRISA ;change register bank or page 1 clrf TRISA clrf TRISB clrf TRISC clrf PORTB ;make PORTB an output port clrf PORTC ;make PORTC an output port banksel PORTA ;change back to original bank/page 0 bcf ANSELH,3 ; Clear pin 12, RB5 bsf TRISB,5 ;=========================================================================== start clrf clrf call PORTB PORTC Delay_40ms ; ; ;

;=========================================================================== _configLCD bcf PORTA,4 ; bcf PORTB,7 ; movlw b'00111100' ; movwf PORTC ; bsf PORTA,5 ; bcf PORTA,5 ; call Delay_37us ; University of the West of England Page 20

UFME69-20-2 Micro-controller Based System

movlw movwf bsf bcf call

b'00111000' PORTC PORTA,5 PORTA,5 Delay_37us

; ; ; ; ;

movlw movwf bsf bcf call

b'00001110' PORTC PORTA,5 PORTA,5 Delay_37us

; ; ; ; ;

movlw movwf bsf bcf call

b'00000001' PORTC PORTA,5 PORTA,5 Delay_37us

; ; ; ; ;

movlw movwf bsf bcf call

b'00000110' PORTC PORTA,5 PORTA,5 Delay_40ms

; ; ; ; ;

;=========================================================================== output bcf movlw movwf bsf bcf call _switch btfss goto PORTB,5 _switch PORTB,7 b'00000001' PORTC PORTA,5 PORTA,5 Delay_40ms ; ; ; ; ;

University of the West of England

Page 21

UFME69-20-2 Micro-controller Based System

_switch1 btfsc goto bsf movlw movwf bsf bcf call _switch2 btfss goto _switch3 btfsc goto bsf bcf movlw movwf bsf bcf call _switch4 btfss goto _switch5 btfsc goto bsf bcf movlw movwf bsf bcf call PORTB,5 _switch5 PORTB,7 PORTA,4 'l' PORTC PORTA,5 PORTA,5 Delay PORTB,5 _switch4 PORTB,5 _switch3 PORTB,7 PORTA,4 'e' PORTC PORTA,5 PORTA,5 Delay PORTB,5 _switch2 PORTB,5 _switch1 PORTB,7 'H' PORTC PORTA,5 PORTA,5 Delay ; ; ; ; ; ;

University of the West of England

Page 22

UFME69-20-2 Micro-controller Based System

_switch6 btfss goto _switch7 btfsc goto bsf bcf movlw movwf bsf bcf call _switch8 btfss goto _switch9 btfsc goto bsf bcf movlw movwf bsf bcf call _switch10 btfss goto _switch11 btfsc goto bcf bcf movlw movwf PORTB,5 _switch11 PORTB,7 PORTA,4 b'11000000' PORTC Page 23 PORTB,5 _switch10 PORTB,5 _switch9 PORTB,7 PORTA,4 'o' PORTC PORTA,5 PORTA,5 Delay PORTB,5 _switch8 PORTB,5 _switch7 PORTB,7 PORTA,4 'l' PORTC PORTA,5 PORTA,5 Delay PORTB,5 _switch6

University of the West of England

UFME69-20-2 Micro-controller Based System

bsf bcf call _switch12 btfss goto _switch13 btfsc goto bsf bcf movlw movwf bsf bcf call _switch14 btfss goto _switch15 btfsc goto bsf bcf movlw movwf bsf bcf call _switch16 btfss goto _switch17 btfsc goto

PORTA,5 PORTA,5 Delay

; Setting and clearing A5 to clock ; the data into the device ;

PORTB,5 _switch12

PORTB,5 _switch13 PORTB,7 PORTA,4 'W' PORTC PORTA,5 PORTA,5 Delay ; ; ; Move letter 'W' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ;

PORTB,5 _switch14

PORTB,5 _switch15 PORTB,7 PORTA,4 'o' PORTC PORTA,5 PORTA,5 Delay ; ; ; Move letter 'o' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ;

PORTB,5 _switch16

PORTB,5 _switch17

University of the West of England

Page 24

UFME69-20-2 Micro-controller Based System

bsf bcf movlw movwf bsf bcf call _switch18 btfss goto _switch19 btfsc goto bsf bcf movlw movwf bsf bcf call _switch20 btfss goto _switch21 btfsc goto bsf bcf movlw movwf bsf bcf call _switch22 btfss goto

PORTB,7 PORTA,4 'r' PORTC PORTA,5 PORTA,5 Delay

; ; ; Move letter 'r' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ;

PORTB,5 _switch18

PORTB,5 _switch19 PORTB,7 PORTA,4 'l' PORTC PORTA,5 PORTA,5 Delay ; ; ; Move letter 'l' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ;

PORTB,5 _switch20

PORTB,5 _switch21 PORTB,7 PORTA,4 'd' PORTC PORTA,5 PORTA,5 Delay ; ; ; Move letter 'd' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ;

PORTB,5 _switch22

University of the West of England

Page 25

UFME69-20-2 Micro-controller Based System

_switch23 btfsc goto bsf bcf movlw movwf bsf bcf call PORTB,5 _switch23 PORTB,7 PORTA,4 '!' PORTC PORTA,5 PORTA,5 Delay ; ; ; Move letter '!' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ;

goto output ;=============================================================================== Delay_37us movlw movwf Delay_loop decfsz goto return Delayreg Delay_loop 0x07 Delayreg

;=============================================================================== Delay_40ms movlw movwf Delay401 movlw movwf Delay40loop decfsz goto decfsz goto return ;============================================================================== Delayreg2 Delay40loop Delayreg Delay401 0xFF Delayreg2 0x1F Delayreg

University of the West of England

Page 26

UFME69-20-2 Micro-controller Based System

Delay movlw movwf Delay_A movlw movwf Delay_B movlw movwf loop1 decfsz goto decfsz goto decfsz goto return outer movlw movwf routene decfsz goto decfsz goto return End Delayreg2 routene Delayreg outer 0x03 Delayreg2 Delayreg3 loop1 Delayreg2 Delay_B Delayreg Delay_A 0x07 Delayreg3 0x0F Delayreg2 0xFF Delayreg

; This tells the assembler this is all

University of the West of England

Page 27

UFME69-20-2 Micro-controller Based System

Task 4 ;************************************************************************* ;Written by : Noor Hasanah Mohd Nazri ;Date : 17/01/2012 ;Version : ;File saved as : Hello World1 ;For PIC : 18F14K22 ;************************************************************************* ;Program Function : LCD module displays "Hello World!" ;************************************************************************* include "P18F14K22.INC" ;This tells the assembler to include ;another source file Delayreg EQU H'21' Delayreg2 EQU H'22' Delayreg3 EQU H'23' ;========================================================================== banksel clrf clrf clrf clrf clrf banksel bcf bsf TRISA TRISA TRISB TRISC PORTB PORTC PORTA ANSELH,3 TRISB,5 ;change register bank or page 1

;make PORTB an output port ;make PORTC an output port ;change back to original bank/page 0

;=========================================================================== start clrf clrf call PORTB PORTC Delay_40ms ; ; ;

;=========================================================================== _configLCD bcf PORTA,4 ; bcf PORTB,7 ; movlw b'00111100' ; movwf PORTC ; bsf PORTA,5 ; bcf PORTA,5 ; University of the West of England Page 28

UFME69-20-2 Micro-controller Based System

call

Delay_37us

movlw movwf bsf bcf call

b'00111000' PORTC PORTA,5 PORTA,5 Delay_37us

; ; ; ; ;

movlw movwf bsf bcf call

b'00001110' PORTC PORTA,5 PORTA,5 Delay_37us

; ; ; ; ;

movlw movwf bsf bcf call

b'00000001' PORTC PORTA,5 PORTA,5 Delay_37us

; ; ; ; ;

movlw movwf bsf bcf call

b'00000110' PORTC PORTA,5 PORTA,5 Delay_40ms

; ; ; ; ;

;=========================================================================== display bcf movlw movwf bsf bcf call bsf movlw movwf bsf PORTB,7 b'00000001' PORTC PORTA,5 PORTA,5 Delay_40ms PORTB,7 'S' PORTC PORTA,5 ; ; ; ; ; ; ; ; ; Page 29

University of the West of England

UFME69-20-2 Micro-controller Based System

bcf call bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call ; ; ; ; ; ; ; bsf bcf movlw movwf bsf bcf call bcf bcf movlw movwf bsf bcf call bsf

PORTA,5 Delay PORTB,7 PORTA,4 'I' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 'G' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 'N' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 'o' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 b'11000000' PORTC PORTA,5 PORTA,5 Delay PORTB,7

; ; ; ; ; Move letter 'e' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; ; ; Move letter 'l' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; ; ; Move letter 'l' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; ; ; Move letter 'o' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; ; ; ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; Clear RW pin Page 30

University of the West of England

UFME69-20-2 Micro-controller Based System

bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf bcf call bsf bcf movlw movwf bsf

PORTA,4 'O' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 'N' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 'r' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 'l' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 'd' PORTC PORTA,5 PORTA,5 Delay PORTB,7 PORTA,4 '!' PORTC PORTA,5

; ; Move letter 'W' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; ; ; Move letter 'o' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; ; ; Move letter 'r' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; ; ; Move letter 'l' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; ; ; Move letter 'd' into W register ; Send data to PORTC ; Setting and clearing A5 to clock ; the data into the device ; ; ; ; Move letter '!' into W register ; Send data to PORTC ; Setting and clearing A5 to clock Page 31

University of the West of England

UFME69-20-2 Micro-controller Based System

; ;

bcf call

PORTA,5 Delay

; the data into the device ;

goto output ;============================================================================== output bcf movlw movwf bsf bcf call _switch btfss goto _switch1 btfsc goto bsf movlw movwf bsf bcf call PORTB,5 _switch1 PORTB,7 'V' PORTC PORA,5 PORTA,5 Delay_37us ; ; ; ; ; PORTB,5 _switch PORTB,7 b'00000001' PORTC PORTA,5 PORTA,5 Delay_40ms ; ; ; ; ;

bsf movlw movwf bsf bcf call

PORTB,7 'o' PORTC PORTA,5 PORTA,5 Delay_37us

bsf movlw movwf bsf bcf

PORTB,7 'l' PORTC PORTA,5 PORTA,5 Page 32

University of the West of England

UFME69-20-2 Micro-controller Based System

call bsf movlw movwf bsf bcf call

Delay_37us PORTB,7 't' PORTC PORTA,5 PORTA,5 Delay_37us

bsf PORTB,7 movlw 's' movwf PORTC bsf PORTA,5 bcf PORTA,5 call Delay_37us sleep ;=============================================================================== Delay_37us movlw 0x07 movwf Delayreg Delay_loop decfsz goto return Delayreg Delay_loop

;=============================================================================== Delay_40ms movlw movwf Delay401 movlw movwf Delay40loop decfsz goto decfsz goto return University of the West of England Page 33 Delayreg2 Delay40loop Delayreg Delay401 0xFF Delayreg2 0x1F Delayreg

UFME69-20-2 Micro-controller Based System

;=============================================================================== Delay movlw movwf Delay_A movlw movwf Delay_B movlw movwf loop1 decfsz goto decfsz goto decfsz goto return ;outer ; ; ;routene ; ; ; ; ; Delayreg3 loop1 Delayreg2 Delay_B Delayreg Delay_A 0x07 Delayreg3 0x0F Delayreg2 0xFF Delayreg

movlw movwf

0x03 Delayreg2

decfsz goto decfsz goto return End

Delayreg2 routene Delayreg outer

; This tells the assembler this is all

University of the West of England

Page 34

Anda mungkin juga menyukai