;-------------------------------; ; Budik ; ;-------------------------------; ; slovak@post.cz )S(04.2006 ; ;-------------------------------; ; LIST P=16F628A, R=DEC ; direktivy prekladace include ; definice nazvu registru __CONFIG 0x3F62 ; CP=OFF, CPD=OFF, LVP=OFF, BOREN=ON, MCLRE=MCLR ; PWRTEN=ENABLE, WDTE=OFF, OSC=HS ; Xtal = 4194304 Hz cblock 0x20 Mem_Stat Mem_W Flag ;priznaky SdelN ;sek.delic nizsi SdelV ;sek.delic vyzsi (2000/2000) Ddel ;displej delic (2000/4) Tecky ;deesetine tecky 0=sviti anody ;tranzistor anody 0=sepnut katody ;katody segmentu displeje 0=sviti Dis0 ;displej cislo 0 Dis1 ;displej cislo 1 Dis2 ;displej cislo 2 Dis3 ;displej cislo 3 Dis4 ;displej cislo 4 Dis5 ;displej cislo 5 KlvP ;cislo stisknueho tlacitka Sek ;Sekundy 0-59 Min ;Minuty 0-59 Hod ;Hodiny 0-23 BMin ;budik Minuty 0-59 BHod ;budik Hodiny 0-23 OSek ;Odpocet sekundy 59-0 OMin ;Odpocet minuty 99-0 PiPo ;Pipo sekundy 99-0 PamO ;pamet pro Odpocet PamP ;pamet pro Pipo CMH ;citac pro navrat do modu hodin Hotovo ;dokoncene procesy 1=hotovo KdelN ;delicN pro opakovani KLV KdelV ;delicV pro opakovani KLV R1 ;rad jednicek R10 ;rad desitek BLIK ;delic pro blikani displeje endc #define TAl Tecky,2 ;tecka alarmu #define TVt Tecky,0 ;tecka vterim #define TNap Tecky,4 ;tecka napajeni #define FOd Flag,0 ;odpocet (1=odecita) #define FPipo Flag,1 ;pipani po limitu (1=odecita) #define FPres Flag,2 ;stisknuti klavesy (1=stisknuta) #define FStop Flag,3 ;zastaveni hodin pri nastavovani (1=stop) #define FPip Flag,4 ;zvonek (1=zvonit) #define FSet Flag,5 ;opakovani TlN #define Fnap Flag,6 ;napajeni OK=0 #define HOd Hotovo,0;odecet dokoncen #define HPipo Hotovo,1;pipo dokoncen #define HSek Hotovo,2;uplynula sekunda #define HBud Hotovo,3;shoda hodiny budik #define HMh Hotovo,4;prepnout na mod hodin #define Hklv Hotovo,5;opakovat KLV #define OE PORTA,0 ;portA bit0 pin17 vystup OE #define CK PORTA,1 ;portA bit1 pin18 vystup CK #define REPRO PORTA,2 ;portA bit2 pin1 vystup reproduktor #define RELE PORTA,3 ;portA bit3 pin2 vystup rele (0=vyp) #define Utest PORTA,4 ;portA bit4 pin3 vstup pro test napajeni (0=vyp) #define TlN KlvP,0 ;KlvPort bit3 pin9 tlacitko Nastavit #define TlD KlvP,1 ;KlvPort bit2 pin8 tlacitko Displej #define TlA KlvP,2 ;KlvPort bit1 pin7 tlacitko Alarm #define TlV KlvP,3 ;KlvPort bit0 pin6 tlacitko Volba ;======================================== ; kod programu ;---------------------------------------- ORG 0 GOTO Start ; skok na zacatek programu CALL 41 CALL 83 CALL 40 GOTO IntProc ; skok na obsluhu preruseni ;======================================== ; podprogramy ;---------------------------------------- ;prevod cislo znaku/sedmisegment SEGMENT MOVWF R10 ; SUBLW 0x24 ;24-Seg MOVF R10,W ;puvodni znak BTFSS STATUS,C ;kladne? MOVLW 0x20 ;NE, nahradit znak ADDWF PCL,F ;ANO RETLW 0xC0 ;00/0 RETLW 0xF9 ;01/1 RETLW 0xA4 ;02/2 RETLW 0xB0 ;03/3 RETLW 0x99 ;04/4 RETLW 0x92 ;05/5 RETLW 0x82 ;06/6 RETLW 0xF8 ;07/7 RETLW 0x80 ;08/8 RETLW 0x90 ;09/9 RETLW 0x88 ;0A/A RETLW 0x83 ;0B/b RETLW 0xC6 ;0C/C RETLW 0xA1 ;0D/d RETLW 0x86 ;0E/E RETLW 0x8E ;0F/F RETLW 0x89 ;10/H RETLW 0xEF ;11/i RETLW 0xE1 ;12/J RETLW 0x8F ;13/k RETLW 0xC7 ;14/L RETLW 0xC8 ;15/M RETLW 0xAB ;16/n RETLW 0xA3 ;17/o RETLW 0x8C ;18/P RETLW 0xAF ;19/r RETLW 0x87 ;1A/t RETLW 0xE3 ;1B/u RETLW 0xC1 ;1C/V RETLW 0x8D ;1D/Y RETLW 0xBF ;1E/- RETLW 0xB9 ;1F/-1(-10) RETLW 0xFF ;20/ (vypnuty displej) RETLW 0xB7 ;21/= (-20) RETLW 0xB6 ;22/. (-30) RETLW 0x9B ;23/. (-40) RETLW 0xF0 ;24/) ;---------------------------------------- ;test KLV+opakovani, Z=0=neco stisknuto, Z=1=zadne tlacitko KLV MOVF KlvP,W ANDLW 0x0F ;00001111 1a1=1 XORLW 0x0F ;00001111 st.=0 BTFSS STATUS,Z ;Z=1, nenulove? (zadne tlacitko) GOTO Neco ;NE BCF FPres ;vynulovat priznak BCF FSet ;vynulovat priznak pro TlN RETURN Neco BTFSS FPres ;=1? znova GOTO Prvni ;NE BTFSS Hklv ;=1? opakovat KLV GOTO Nic ;NE Prvni CLRF KdelN ;nulovat delicN KLV MOVLW 2 ;zpozdeni 0.25s BTFSS TlN ;stisknuto TlN? MOVLW 24 ;ANO, zpozdeni 3s MOVWF KdelV ;nastavit delicV KLV BCF Hklv ;opakovat KLV =0 BSF FPres ;Pres=1 BCF STATUS,Z ;Z=0 RETURN Nic BSF STATUS,Z ;Z=1 RETURN ;jako zadne tl. ;---------------------------------------- KLV1 MOVF KlvP,W ANDLW 0x0F ;00001111 1a1=1 XORLW 0x0F ;00001111 st.=0 BTFSS STATUS,Z ;Z=1, nenulove? (zadne tlacitko) GOTO Neco1 ;NE BCF FPres ;vynulovat priznak BCF FSet ;vynulovat priznak pro TlN RETURN Neco1 BTFSS FPres ;=1? znova GOTO Prvni1 ;NE BTFSS Hklv ;=1? opakovat KLV GOTO Nic ;NE Prvni1 CLRF KdelN ;nulovat delicN KLV MOVLW 24 ;zpozdeni 3s. MOVWF KdelV ;nastavit delicV KLV BCF Hklv ;opakovat KLV =0 BSF FPres ;Pres=1 BCF STATUS,Z ;Z=0 RETURN ;---------------------------------------- HEXDEC MOVWF R1 ; CLRF R10 ;=0 Rad10 MOVLW 10 ;vypocet radu desitek SUBWF R1,W ;-10 BTFSS STATUS,C ;kladne? GOTO End10 ;NE, hotovo MOVWF R1 ;ulozit rad jednicek INCF R10,F ;+1 GOTO Rad10 ;zpet End10 MOVF R10,W ;rad desitek RETURN ;---------------------------------------- HBUDIK BTFSC TAl ;zap alarm? RETURN ;NE BTFSS HBud ;buzeni? RETURN ;NE BSF FPipo ;zap Pipo BCF RELE ;vyp rele RETURN ;---------------------------------------- NEWHOD MOVF Hod,W ;hodiny CALL HEXDEC ;vrati R1,R10=W CALL SEGMENT MOVWF Dis5 ;Hod desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis4 ;Hod jednicky NEWHODM MOVF Min,W ;minuty CALL HEXDEC CALL SEGMENT MOVWF Dis3 ;Min desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis2 ;Min jednicky MOVF Sek,W ;sekundy CALL HEXDEC CALL SEGMENT MOVWF Dis1 ;Sek desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis0 ;Sek jednicky BCF HSek ;=0 RETURN ;---------------------------------------- NEWBUD MOVF BHod,W CALL HEXDEC CALL SEGMENT MOVWF Dis5 ;Budik Hod desitky MOVF R1,W CALL SEGMENT MOVWF Dis4 ;Budik Hod jednicky NEWBUDM MOVF BMin,W CALL HEXDEC CALL SEGMENT MOVWF Dis3 ;Budik Min desitky MOVF R1,W CALL SEGMENT MOVWF Dis2 ;Budik Min jednicky MOVLW 0x0B ;znak b CALL SEGMENT MOVWF Dis1 ;b MOVLW 0x1B ;znak u CALL SEGMENT MOVWF Dis0 ;u RETURN ;---------------------------------------- NEWODP MOVF OMin,W CALL HEXDEC CALL SEGMENT MOVWF Dis3 ;Od Min desitky MOVF R1,W CALL SEGMENT MOVWF Dis2 ;Od Min jednicky MOVF OSek,W CALL HEXDEC CALL SEGMENT MOVWF Dis1 ;Od Sek desitky MOVF R1,W CALL SEGMENT MOVWF Dis0 ;Od Sek jednicky MOVLW 0x17 ;kod znaku -o- CALL SEGMENT MOVWF Dis5 ;-o- MOVLW 0x0D ;kod znaku -d- CALL SEGMENT MOVWF Dis4 ;-d- BCF HSek ;=0 RETURN ;---------------------------------------- NEWPIPO MOVF PiPo,W CALL HEXDEC CALL SEGMENT MOVWF Dis1 ;PiPo Sek desitky MOVF R1,W CALL SEGMENT MOVWF Dis0 ;PiPo Sek jednicky MOVLW 0x18 ;kod znaku -P- CALL SEGMENT MOVWF Dis5 ;-P- MOVWF Dis3 ;-P- MOVLW 0x11 ;kod znaku -i- CALL SEGMENT MOVWF Dis4 ;-i- MOVLW 0x17 ;kod znaku -o- CALL SEGMENT MOVWF Dis2 ;-o- BCF HSek ;=0 RETURN ;---------------------------------------- ALARM BTFSS TAl ;vyp alarm? GOTO AL BCF TAl ;zap alarm BSF FOd ;povolit Od RETURN AL BSF TAl ;vyp alarm BCF FPip ;nezvonit BCF FOd ;zakazat Od MOVLW 11 MOVWF OSek MOVF PamO,W MOVWF OMin BCF FPipo BCF HPipo MOVF PamP,W MOVWF PiPo BCF FPip BCF RELE ;vyp rele RETURN ;---------------------------------------- HPIPOL BTFSS TAl BTFSS HPipo RETURN BSF FPip ;zvonit RETURN ;======================================== ; preruseni ;---------------------------------------- ;frekvence preruseni=2048Hz IntProc MOVWF Mem_W MOVF STATUS,W ;ulozeni obsahu MOVWF Mem_Stat ; STATUS ;delic pro KLV DECFSZ KdelN,F ;-1,=0? GOTO Zvonek DECFSZ KdelV,F ;-1,=0? GOTO Zvonek BSF Hklv ;=1 Zvonek BTFSS FPip ;zvonit? GOTO NePip ;NE BTFSS SdelV,2 ;prerusene? GOTO NePip ;ANO MOVLW 0x04 ;00000100 XORWF PORTA,F ;stejne=0 (inverze bitu REPRO) BTFSS FPip ;pri klidu NePip BCF REPRO ; vystup REPRO=0 ;delic pro sekundu (/2048) DECFSZ SdelN,F ;-1,=0? GOTO DELDIS ;NE DECFSZ SdelV,F ;-1,=0? GOTO DELDIS ;NE MOVLW 8 ;od MOVWF SdelV ; znova CALL SEKUNDA ;delic pro displej (/5) DELDIS DECFSZ Ddel,F ;-1,=0? GOTO EndIP ;NE MOVLW 5 ;od MOVWF Ddel ; znova CALL PRINT ;zobrazit displej ;konec preruseni EndIP BCF INTCON,T0IF ;priznak preruseni=0 MOVF Mem_Stat,W ;obnova MOVWF STATUS ; stavu STATUS SWAPF Mem_W,F SWAPF Mem_W,W RETFIE ;navrat z preruseni ;---------------------------------------- PRINT ;delic pro blikani displeje INCF BLIK,F ;+1 ;test napajeni BTFSS Utest ;napajeni? GOTO TN ;NE BCF Fnap ;priznak napajeni=0 GOTO Nak TN BTFSS Fnap ;priznak napajeni? BSF HOd ;vyp dis BSF TNap ;vyp tecku napajeni BSF Fnap ;priznak napajeni=1 BTFSC SdelV,3 ;blikat GOTO Nak ;neni napajeni MOVLW 0xFF ;vyp displej MOVWF Dis5 ; MOVWF Dis4 ; MOVWF Dis3 ; MOVWF Dis2 ; MOVWF Dis1 ; MOVWF Dis0 ; ;Nova anoda katoda Nak BSF STATUS,C ;C=1 RLF anody,F ;rotace vlevo BTFSC anody,6 ;=0? GOTO Pt ;76543210 MOVLW 0xFE ;11111110 MOVWF anody ;nove anody MOVF Dis0,W ;Displej0 Pt BTFSS anody,1 ;=1? MOVF Dis1,W ;Displej1 BTFSS anody,2 ;=1? MOVF Dis2,W ;Displej2 BTFSS anody,3 ;=1? MOVF Dis3,W ;Displej3 BTFSS anody,4 ;=1? MOVF Dis4,W ;Displej4 BTFSS anody,5 ;=1? MOVF Dis5,W ;Displej5 MOVWF katody ;nove katody ;pridat tecku MOVF anody,W XORLW 0xFF ;stejne=0 (invertovat) ANDWF Tecky,W ;1a1=1 test BTFSC STATUS,Z ;Z=0? tecka=1 BCF katody,7 ;bit7=0=zap tecku BCF anody,7 ;led nesviti ;zhasnout displej BSF OE ;OE=1 (vyp anody) ;CteniKLV MOVLW 0xFF ;11111111 MOVWF PORTB ;vystupy PB=1 BSF STATUS,RP0 ;reg.sada1 MOVWF TRISB ;1=vstupy BCF STATUS,RP0 ;reg.sada0 MOVF PORTB,W ;cteni KLV MOVWF KlvP ;ulozit BSF STATUS,RP0 ;reg.sada1 CLRF TRISB ;0=vystupy BCF STATUS,RP0 ;reg.sada0 ;rosvitit displej MOVF anody,W ;nove anody MOVWF PORTB ; BSF CK ;CK=1 (load) MOVF katody,W ;nove katody BCF CK ;CK=0 MOVWF PORTB ; BCF OE ;OE=0 (zap! anody) RETURN ;---------------------------------------- SEKUNDA ;stop hodiny? BTFSC FStop ;=0? test stop hodiny RETURN ;ANO ;sekundy+1 INCF Sek,F ;+1 MOVF Sek,W ;test SUBLW 59 ; 59-Sek BTFSC STATUS,C ;C=0? zaporne GOTO OD ;NE CLRF Sek ;=0 ;minuty+1 INCF Min,F ;+1 MOVF Min,W ;test SUBLW 59 ; 59-Min1 BTFSC STATUS,C ;C=0? zaporne GOTO OD ;NE CLRF Min ;=0 ;hodiny+1 INCF Hod,F ;+1 MOVF Hod,W ;test SUBLW 23 ; 23-Min1 BTFSS STATUS,C ;C=1? kladne CLRF Hod ;NE;=0 ;---------------------------------------- OD BTFSS RELE ;=1? ZAP? BTFSS FOd ;=1? priznak pro odpocet GOTO PIPOLIM ;NE ;OSek-1 MOVLW 1 SUBWF OSek,F ;OSek-1 BTFSC STATUS,C ;C=0? zaporne GOTO PIPOLIM ;NE MOVLW 59 ;znova MOVWF OSek ; ;OMin-1 MOVLW 1 SUBWF OMin,F ;OMin-1 BTFSC STATUS,C ;C=0? zaporne GOTO PIPOLIM ;NE ;konec odpocitavani MOVF PamO,W ;znova MOVWF OMin ; obnovit MOVLW 11 ;znova MOVWF OSek ; obnovit BCF FOd ;=0 zakazat odpocet BSF HOd ;=1 hotovo ;---------------------------------------- PIPOLIM BTFSS FPipo ;=1? priznak pro pipani po limitu GOTO MHod ;NE ;PiPo-1 MOVLW 1 SUBWF PiPo,F ;PiPo-1 BTFSC STATUS,C ;C=0? zaporne GOTO MHod ;NE ;konec odpocitavani MOVF PamP,W ;znova MOVWF PiPo ; BCF FPipo ;=0 zakazat odpocet BSF HPipo ;=1 hotovo ;---------------------------------------- ;citac pro navrat do modu hodin +1 MHod INCFSZ CMH,F ;+1, =0? GOTO THB ;NE BSF HMh ;=1 prepnout na mod hodiny ;---------------------------------------- ;test Hodiny-Budik THB BCF HBud ;=0 MOVF Hod,W ;test hodiny SUBWF BHod,W ;BHod-Hod BTFSS STATUS,Z ;Z=1? nulove GOTO ESEK ;NE MOVF Min,W ;test minuty SUBWF BMin,W ;BMin-Min BTFSC STATUS,Z ;Z=0? nenulove BSF HBud ;=1=shoda ;---------------------------------------- ;konec sekunda ESEK BSF HSek ;=1 uplynula jedna sekunda RETURN ;============================================================================= ; hlavni program ;---------------------------------------- Start MOVLW 0x07 ;inicializace procesoru MOVWF CMCON ; BSF STATUS,RP0 ;registrova sada 1 CLRF OPTION_REG ;00000000 MOVLW 0xF0 ;11110000 MOVWF TRISA ;PA vystupy mimo A4 CLRF TRISB ;PB vystupy BCF STATUS,RP0 ;registrova sada 0 CLRF PORTA ;00000000 MOVLW 0xA0 ;10100000 MOVWF INTCON ;preruseni pro TMR0 MOVLW 0xFF MOVWF Tecky CLRF anody CLRF Hotovo CLRF Flag CLRF Hod CLRF Min CLRF Sek CLRF BMin MOVLW 5 MOVWF BHod MOVLW 11 MOVWF OSek MOVLW 1 MOVWF SdelV CLRF OMin CLRF PiPo CLRF PamO CLRF PamP CLRF CMH ;---------------------------------------- ;mod hodiny BSF HSek ;=1 prvni zobrazeni HOD BTFSS HSek ;=1? GOTO HODH ;NE HODINY BCF FStop ;spustit hodiny BSF TVt ;vyp tectu vterin BTFSC Utest ;neni napajeni? BCF TNap ;zap tecku napajeni MOVF Hod,W ;hodiny CALL HEXDEC ;vrati R1,R10=W BTFSC STATUS,Z ;C=0? nenulove MOVLW 0x20 ;nezobrazovat nulu CALL SEGMENT MOVWF Dis5 ;Hod desitky MOVF R1,W ;rad jednicek CALL SEGMENT MOVWF Dis4 ;Hod jednicky CALL NEWHODM HODH CALL HBUDIK ;hlidani budiku CALL HPIPOL ;hlidani PiPo BTFSC HOd ;=0? GOTO DISPLEJ CALL HPIPOL CALL KLV1 BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO HOD ;NE BTFSS TlN ;stisknuto? GOTO NHOD ;ANO BTFSS TlD ;stisknuto? GOTO DISPLEJ ;ANO BTFSS TlV ;stisknuto? GOTO BUDIK ;ANO CALL ALARM GOTO HOD ;---------------------------------------- ;mod budik ;navrat BUDIK BSF HSek ;=1 prvni zobrazeni BCF HMh ;=0 aktivace navrat CLRF CMH ; BUDH BTFSS HSek ;=1? GOTO BUDHL ;NE MOVF BHod,W CALL HEXDEC BTFSC STATUS,Z MOVLW 0x20 ;nezobrazovat nulu CALL SEGMENT MOVWF Dis5 ;Budik Hod desitky MOVF R1,W CALL SEGMENT MOVWF Dis4 ;Budik Hod jednicky CALL NEWBUDM BUDHL BTFSC HMh ;=0? navrat GOTO HODINY CALL HBUDIK CALL HPIPOL ;hlidani PiPo BTFSC HOd ;=0? GOTO DISPLEJ BTFSC SdelV,3 ;=0? BCF TVt ;zap tecku vterin BTFSS SdelV,3 ;=1? BSF TVt ;vyp tecku vterin CALL KLV1 BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO BUDH ;NE BTFSS TlN ;stisknuto? GOTO NBUD ;ANO BTFSS TlD ;stisknuto? GOTO DISPLEJ ;ANO BTFSS TlV ;stisknuto? GOTO ODPOCET ;ANO CALL ALARM GOTO BUDH ;---------------------------------------- ;mod odpocet ODPOCET BSF HSek ;=1 prvni zobrazeni CLRF CMH ODP BTFSC HSek ;=0? CALL NEWODP HODPOCET BTFSC HMh ;=0? navrat GOTO HODINY CALL HBUDIK CALL HPIPOL ;hlidani PiPo BTFSC HOd ;=0? GOTO DISPLEJ BTFSC SdelV,3 ;=0? BCF TVt ;zap tecku vterin BTFSS SdelV,3 ;=1? BSF TVt ;vyp tecku vterin CALL KLV1 BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO ODP ;NE BTFSS TlN ;stisknuto? GOTO NODP ;ANO BTFSS TlD ;stisknuto? GOTO DISPLEJ ;ANO BTFSS TlV ;stisknuto? GOTO MPIPO ;ANO CALL ALARM GOTO ODP ;---------------------------------------- ;mod pipo MPIPO BSF HSek ;=1 prvni zobrazeni CLRF CMH PIPOL BTFSC HSek ;=0? CALL NEWPIPO BTFSC HMh ;=0? navrat GOTO HODINY CALL HBUDIK CALL HPIPOL ;hlidani PiPo BTFSC HOd ;=0? GOTO DISPLEJ BTFSC SdelV,3 ;=0? BCF TVt ;zap tecku vterin BTFSS SdelV,3 ;=1? BSF TVt ;vyp tecku vterin CALL KLV1 BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO PIPOL ;NE BTFSS TlN ;stisknuto? GOTO NPIPO ;ANO BTFSS TlD ;stisknuto? GOTO DISPLEJ ;ANO BTFSS TlV ;stisknuto? GOTO HODINY CALL ALARM ;ANO GOTO MPIPO ;---------------------------------------- ;nastavit hodiny NHOD BTFSC FSet ;prvni? GOTO BLHODINY ;NE BSF FSet ;=1 GOTO HOD BLHODINY CLRF BLIK BSF TVt BLHOD BTFSS BLIK,7 GOTO BLHODIN MOVLW 0xFF ;zadny znak MOVWF Dis5 ;vyp Hod desitky MOVWF Dis4 ;vyp Hod jednicky GOTO BLHODI BLHODIN CALL NEWHOD BLHODI CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO BLHOD ;NE BTFSS TlN ;stisknuto? GOTO ESH ;ANO BTFSS TlD ;stisknuto? GOTO HODMINUS ;ANO BTFSS TlA ;stisknuto? GOTO HODPLUS ;ANO ;---------------------------------------- BLMINUTY CLRF BLIK BLMIN BTFSS BLIK,7 GOTO BLMINUT MOVLW 0xFF MOVWF Dis3 MOVWF Dis2 GOTO BLMINU BLMINUT CALL NEWHOD BLMINU CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO BLMIN ;NE BTFSS TlN ;stisknuto? GOTO ESH ;ANO BTFSS TlD ;stisknuto? GOTO MINMINUS ;ANO BTFSS TlA ;stisknuto? GOTO MINPLUS ;ANO ;---------------------------------------- NULSEK BSF FStop ;stop hodiny CLRF Sek GOTO BLHODINY ;---------------------------------------- HODMINUS MOVLW 1 SUBWF Hod,F ;Hod-1 BTFSC STATUS,C ;C=0? zaporne GOTO BLHODINY ;NE MOVLW 23 ;znova MOVWF Hod ; GOTO BLHODINY ;---------------------------------------- HODPLUS INCF Hod,F ;Hod+1 MOVF Hod,W ;test SUBLW 23 ; 23-Hod BTFSS STATUS,C ;C=0? kladne CLRF Hod ;NE;=0 GOTO BLHODINY ;---------------------------------------- MINMINUS MOVLW 1 SUBWF Min,F ;Min-1 BTFSC STATUS,C ;C=0? zaporne GOTO BLMINUTY ;NE MOVLW 59 ;znova MOVWF Min ; GOTO BLMINUTY ;---------------------------------------- MINPLUS INCF Min,F ;Min+1 MOVF Min,W ;test SUBLW 59 ; 59-Min BTFSS STATUS,C ;C=0? kladne CLRF Min ;NE;=0 GOTO BLMINUTY ;---------------------------------------- ;sekunda od nuly ESH BTFSS FStop ;=1? test stop hodiny GOTO HODINY ;NE MOVLW 0xD0 MOVWF SdelN MOVLW 8 MOVWF SdelV CLRF TMR0 GOTO HODINY ;---------------------------------------- ;nastavit budik NBUD BTFSC FSet ;prvni? GOTO BLBUDHODINY ;NE BSF FSet ;=1 GOTO BUDIK BLBUDHODINY CLRF BLIK BSF TVt BLBUDHODIN BTFSS BLIK,7 ;=0? GOTO BLBUDHOD MOVLW 0xFF ;kod prazdneho znaku MOVWF Dis5 ;vyp Hod desitky MOVWF Dis4 ;vyp Hod jednicky GOTO BLBUDHODI BLBUDHOD CALL NEWBUD BLBUDHODI CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO BLBUDHODIN ;NE BTFSS TlN ;stisknuto? GOTO BUDIK ;ANO BTFSS TlD ;stisknuto? GOTO BUDHODMINUS ;ANO BTFSS TlA ;stisknuto? GOTO BUDHODPLUS ;ANO ;---------------------------------------- BLBUDMINUTY CLRF BLIK BLBUDMINUT BTFSS BLIK,7 GOTO BLBUDMIN MOVLW 0xFF MOVWF Dis3 MOVWF Dis2 GOTO BLBUDMINU BLBUDMIN CALL NEWBUD BLBUDMINU CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO BLBUDMINUT ;NE BTFSS TlN ;stisknuto? GOTO BUDIK ;ANO BTFSS TlD ;stisknuto? GOTO BUDMINMINUS ;ANO BTFSS TlA ;stisknuto? GOTO BUDMINPLUS ;ANO GOTO BLBUDHODINY ;---------------------------------------- BUDHODMINUS MOVLW 1 SUBWF BHod,F ;BHod-1 BTFSC STATUS,C ;C=0? zaporne GOTO BLBUDHODINY ;NE MOVLW 23 ;znova MOVWF BHod ; GOTO BLBUDHODINY ;---------------------------------------- BUDHODPLUS INCF BHod,F ;BHod+1 MOVF BHod,W ;test SUBLW 23 ; 23-Hod BTFSS STATUS,C ;C=0? kladne CLRF BHod ;NE;=0 GOTO BLBUDHODINY ;---------------------------------------- BUDMINMINUS MOVLW 1 SUBWF BMin,F ;BMin-1 BTFSC STATUS,C ;C=0? zaporne GOTO BLBUDMINUTY ;NE MOVLW 59 ;znova MOVWF BMin ; GOTO BLBUDMINUTY ;---------------------------------------- BUDMINPLUS INCF BMin,F ;BMin+1 MOVF BMin,W ;test SUBLW 59 ; 59-Min BTFSS STATUS,C ;C=0? kladne CLRF BMin ;NE;=0 GOTO BLBUDMINUTY ;---------------------------------------- ;nastavit odpocet NODP BTFSC FSet ;prvni? GOTO BLODPOCET ;NE BSF FSet ;=1 GOTO ODP BLODPOCET CLRF BLIK BSF TVt BLODPOCE BTFSS BLIK,7 ;=0? GOTO BLODPO MOVLW 0xFF ;kod prazdneho znaku MOVWF Dis3 ;vyp Hod desitky MOVWF Dis2 ;vyp Hod jednicky GOTO BLODPOC BLODPO CALL NEWODP BLODPOC CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO BLODPOCE ;NE BTFSS TlN ;stisknuto? GOTO PAMODP ;ANO BTFSS TlD ;stisknuto? GOTO ODPMINUS ;ANO BTFSS TlA ;stisknuto? GOTO ODPPLUS ;ANO GOTO BLODPOCET ;---------------------------------------- PAMODP MOVF OMin,W MOVWF PamO GOTO ODPOCET ;---------------------------------------- ODPMINUS MOVLW 1 SUBWF OMin,F ;OMin-1 BTFSC STATUS,C ;C=0? zaporne GOTO BLODPOCET ;NE MOVLW 99 ;znova MOVWF OMin ; GOTO BLODPOCET ;---------------------------------------- ODPPLUS INCF OMin,F ;BMin+1 MOVF OMin,W ;test SUBLW 99 ; 99-Min BTFSS STATUS,C ;C=0? kladne CLRF OMin ;NE;=0 GOTO BLODPOCET ;---------------------------------------- ;nastavit pipo NPIPO BTFSC FSet ;prvni? GOTO BLPIPOL ;NE BSF FSet ;=1 GOTO PIPOL BLPIPOL CLRF BLIK BSF TVt BLPIPOLI BTFSS BLIK,7 ;=0? GOTO BLPIP MOVLW 0xFF ;kod prazdneho znaku MOVWF Dis1 ;vyp Hod desitky MOVWF Dis0 ;vyp Hod jednicky GOTO BLPI BLPIP CALL NEWPIPO BLPI CALL KLV BTFSC STATUS,Z ;Z=0? neco stisknuto GOTO BLPIPOLI ;NE BTFSS TlN ;stisknuto? GOTO PAMPIPO ;ANO BTFSS TlD ;stisknuto? GOTO PIPOMINUS ;ANO BTFSS TlA ;stisknuto? GOTO PIPOPLUS ;ANO GOTO BLPIPOL ;---------------------------------------- PIPOMINUS MOVLW 1 SUBWF PiPo,F ;PiPo-1 BTFSC STATUS,C ;C=0? zaporne GOTO BLPIPOL ;NE MOVLW 99 ;znova MOVWF PiPo ; GOTO BLPIPOL ;---------------------------------------- PIPOPLUS INCF PiPo,F ;PiPo+1 MOVF PiPo,W ;test SUBLW 99 ; 99-PiPo BTFSS STATUS,C ;C=0? kladne CLRF PiPo ;NE;=0 GOTO BLPIPOL ;---------------------------------------- PAMPIPO MOVF PiPo,W MOVWF PamP GOTO PIPOL ;---------------------------------------- DISPLEJ BTFSS TAl ;vyp alarm? BSF RELE ;NE,zap rele BTFSS Utest ;napajeni? GOTO $+3 ;NE BTFSC TlD ;stisknuto? GOTO HDISPL ;NE MOVLW 0xFF ;kod pro zadny znak MOVWF Dis5 MOVWF Dis4 MOVWF Dis3 MOVWF Dis2 MOVWF Dis1 MOVWF Dis0 HDISP CALL KLV1 BTFSS STATUS,Z ;Z=1? neco stisknuto? GOTO HDISPL ;ANO BTFSC SdelV,3 ;=0? BCF TVt ;zap tecku vterin BTFSS SdelV,3 ;=1? BSF TVt ;vyp tecku vterin BTFSS TAl ;vyp alarm? BTFSS HBud ;=1? GOTO HDISP HDISPL MOVLW 11 ;znovu MOVWF OSek ; odpocet sek MOVF PamO,W ;znovu MOVWF OMin ; odpocet min BCF HOd ;=0 BTFSC TAl ;zap alarm? GOTO HODINY ;NE BTFSS HBud ;souhlasi? BSF FOd ;NE, zap odpocet GOTO HODINY ;---------------------------------------- END ; konec programu