status equ 03h ; Status register address
trisA equ 05h ; Sets direction of the I/O register (port A). This register is in memory bank 1
trisB equ 06h ; Sets direction of the I/O register (port B). This register is in memory bank 1
port_A equ 05h ; address of port A
port_B equ 06h ; address of port B
count1 equ 08h
count2 equ 09h
pulse_on equ 0ffh ; turn pulse on
pulse_off equ 00h ; turn pulse off
rp0 equ 05h ; bit in status register to select register
; bank 1 where trisA reg is stored
all_out equ 00h ; sets all register bits as output
;*******************************************************************
org 0h ; gives instruction to the assembly program to set the program at the first memory location
goto main ; instructs the program to jump to the label "Main"
org 010h ; gives instruction to the assembly program to set this line of the program ;at memory address 0X10
main bsf status, rp0 ; sets the status register so that the program is
;looking a memory block 1 ( what does 0 mean)
movlw all_out ; moves the value of all_out to the working register
movwf trisB ; puts the value from the working register to the special register trisA
bcf status, rp0 ; unsets the flag to the program is back looking at memory block 0
; now port_c is set up as an out put port
; it has taken four lines of to initialise port_c
signal movlw pulse_on ; Now the program can move the value pf Pulse_on to the working register
movwf port_B ; it now moves the value in the working register to port_c
; so the last two lines of code have out put the hex value of 0xff
;*****delay finished now turn the LED ff************
movlw pulse_on
movwf port_B
;****start delay loop******
Loop1 decfsz count1,1 ;subtruct one from 255
goto Loop1 ;if count is ziro, carry on
decfsz count2,1 ;subtruct one from 255
goto Loop1 ; go back to the start of our loop.
;255 to ziro, 255 times
;*****delay finished now turn the LED off************
movlw pulse_off
movwf port_B
;*****adding another dylay************
Loop2 decfsz count1,1 ;subtruct one from 255
goto Loop2 ;if count is ziro, carry on
decfsz count2,1 ;subtruct one from 255
goto Loop2 ; go back to the start of our loop.
;255 to ziro, 255 times
;*****delay finished now turn the LED ff************
goto signal ; this line loops the program so it runs for ever
end ; this is an instruction to the assembler to end the program
|