uaefame
New Member
I am trying to send high and low signal using 16F84 microchip.
My plan is to send 30min delay low in port B,0
Then 58second low in port B,0 then 2 second high in portB,0. The 58second low and 2second high i want it to repeat for 53 times after the delay of 30minutes.
I have the codes here I am confused about calling portB,0 and setting it to low and then using loop for 53times for same instruction.
My plan is to send 30min delay low in port B,0
Then 58second low in port B,0 then 2 second high in portB,0. The 58second low and 2second high i want it to repeat for 53 times after the delay of 30minutes.
I have the codes here I am confused about calling portB,0 and setting it to low and then using loop for 53times for same instruction.
Code:
LIST P=PIC16F84
#INCLUDE "P16F84.INC"
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _LP_OSC
errorlevel -302
cblock 0x0c
d1,d2,d3
endc
org 0
init
banksel TRISA ;bank 1
clrf TRISA
clrf TRISB
banksel PORTB ;bank 0
clrf PORTB
main bsf PORTB,0
call delay30min
bcf PORTB,0
nop ;slight delay for possible RMW problem
bsf PORTB,1
call delay2sec
bcf PORTB,1
nop ;slight delay for possible RMW problem
bsf PORTB,2
call delay5sec
bcf PORTB,2
goto main
delay30min ;30minutes delay
movlw 0xB6
movwf d1
movlw 0x64
movwf d2
movlw 0x20
movwf d3
Delay30min_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay30min_0
nop
return
delay6min59sec ;6minutes 59seconds delay
movlw 0x87
movwf d1
movlw 0x4F
movwf d2
movlw 0x08
movwf d3
delay6min59sec_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto delay6min59sec_0
goto $+1
goto $+1
goto $+1
return
delay9min59sec ;9minutes 59seconds delay
movlw 0x1A
movwf d1
movlw 0x73
movwf d2
movlw 0x0B
movwf d3
delay9min59sec_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto delay9min59sec_0
nop
return
delay58sec ;58seconds delay
movlw 0xED
movwf d1
movlw 0x03
movwf d2
movlw 0x02
movwf d3
Delay58sec_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay58sec_0
return
delay56sec ;56seconds delay
movlw 0xFE
movwf d1
movlw 0xFA
movwf d2
movlw 0x01
movwf d3
Delay56sec_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay56sec_0
goto $+1
goto $+1
nop
return
delay49sec ;49seconds delay
movlw 0xBE
movwf d1
movlw 0xDB
movwf d2
movlw 0x01
movwf d3
delay49sec_0
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto delay49sec_0
goto $+1
goto $+1
nop
return
delay11sec ;11secons delay
movlw 0xBE
movwf d1
movlw 0x45
movwf d2
delay11sec_0
decfsz d1, f
goto $+2
decfsz d2, f
goto delay11sec_0
goto $+1
nop
return
delay5sec ;5seconds delay
movlw 0x3F
movwf d1
movlw 0x20
movwf d2
Delay5sec_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay5sec_0
return
delay4sec ;4seconds delay
movlw 0xFF
movwf d1
movlw 0x19
movwf d2
Delay4sec_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay4sec_0
goto $+1
return
delay2sec ;2seconds delay
movlw 0x7F
movwf d1
movlw 0x0D
movwf d2
Delay2sec_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay2sec_0
return
delay1sec ;1second delay
movlw 0x3E
movwf d1
movlw 0x07
movwf d2
delay1sec_0
decfsz d1, f
goto $+2
decfsz d2, f
goto delay1sec_0
goto $+1
nop
return
end