Blame | Last modification | View Log | Download
#include 16C84.INC
org 0
goto Start
;--------------------
org 4
;--------------------
Start:
page1
movlw 00000000B ; inicializace citace a prescaleru
movwf TMR0
movlw 00000000B ; konfigurace preruseni
movwf INTCON
page1
movlw 11110111B ; nastaveni portu na vstup nebo vystup
movwf PORTA ; 1=vstup 0=vystup
movlw 11110001B
movwf PORTB
bsf TMR0, 7 ; vypni pull-up na PORTB (OPTION registr)
page0
clrw ; vynulovani portu
movwf PORTA
movwf PORTB
bsf PORTA, 3 ; Pull-Up na tlacitka
bcf PORTB, 1 ; zhasnuti LED
bcf PORTB, 2
bcf PORTB, 3
MainLoop:
movlw 2
movwf volani ; Nastavi pocet volani procedury vibito
;bsf PORT ; Nabiti kondenzatoru1
;bsf PORT ; Nabiti kondenzatoru2
dal:
btfss PORTA, 1 ; Test kondenzatoru1
call vibito
bsf PORTB, 2
call Delay10ms
call Delay10ms
call Delay10ms
call Delay10ms
call Delay10ms
bcf PORTB, 2
call Delay10ms
call Delay10ms
call Delay10ms
call Delay10ms
call Delay10ms
bsf PORTB, 2
call Delay10ms
call Delay10ms
call Delay10ms
call Delay10ms
call Delay10ms
bcf PORTB, 2
btfss PORTB, 6 ; Test kondenzatoru2
call vibito
incf Ramec, f
goto dal
;---------------
Delay10us: ; Prodleva (DELAY10 * 10us)+3us
nop
nop
nop
nop
nop
nop
nop
decfsz CT1, 1
goto Delay10us
return
;-------------------------
Sinchro:
bsf PORTB, 1
call Delay10ms
call Delay10ms
call Delay10ms
bcf PORTB, 1 ; 1 impuls (30ms)
call Delay10ms
call Delay10ms
call Delay10ms
bsf PORTB, 1
call Delay10ms
call Delay10ms
bcf PORTB, 1 ; 2 impuls (20ms)
call Delay10ms
call Delay10ms
bsf PORTB, 1
call Delay10ms
bcf PORTB, 1 ; 3 impuls (10ms)
call Delay10ms
return
;-------------------------
Delay10ms:
movlw 100
movwf CT2
call Delay10us
decfsz CT2, f
goto Delay10ms
return
;-------------------------
Protokol:
movlw 8
movwf Bity ; nastaveni slova
call Sinchro
VysBit:
btfss Ramec, 0
call frek0
call frek1
rrf Ramec, f
decfsz Bity, f
goto VysBit
return
;-------------------------
frek0:
;-------------------------
frek1:
;-------------------------
vibito:
movlw 4
movwf CT1 ; uvolneni mista
zapis:
rlf Ramec, f
decfsz CT1, f
goto zapis
decfsz volani, f
return
call Protokol
call MainLoop
;----------------------------
; Definice promenych
;----------------------------
cblock
CT1
CT2
Bity
Ramec
volani
XXX
endc
end