|
Forum elektronikov Forum študentov elektronike
|
Poglej prejšnjo temo :: Poglej naslednjo temo |
Avtor |
Sporočilo |
dkone Študent
Pridružen/-a: 05.11. 2008, 19:54 Prispevkov: 420
|
Objavljeno: 17 Dec 2009 10:56 Naslov sporočila: Tabela za 7-segmentni LED |
|
|
Koda: |
Table
ADDWF PCL,F
RETLW B'11100000'
RETLW B'11111001'
RETLW B'11100100'
RETLW B'11110000'
RETLW B'11111001'
RETLW B'11110010'
Table1
ADDWF PCL,F
RETLW B'11101111'
RETLW B'11111111'
RETLW B'11011111'
RETLW B'11011111'
RETLW B'11001111'
RETLW B'11001111' |
|
|
Nazaj na vrh |
|
|
dkone Študent
Pridružen/-a: 05.11. 2008, 19:54 Prispevkov: 420
|
Objavljeno: 17 Dec 2009 11:30 Naslov sporočila: |
|
|
Koda: |
include P16F877A.inc
__CONFIG _HS_OSC & _WDT_OFF & _PWRTE_ON & _BODEN_OFF & _LVP_OFF & _CPD_OFF & _CP_OFF & _DEBUG_ON
;--------SPREMENLJIVKE---------
ZAK_ST1 EQU 0x20
ZAK_ST2 EQU 0x21
ZAK_ST3 EQU 0x22
TIPKA EQU 0x23
TIP_SS EQU 0x24
STEVEC_PRITISKOV EQU 0x25
STOTINKE EQU 0x26
SEKUNDE EQU 0x27
MINUTE EQU 0x28
URE EQU 0x29
REG_H EQU 0x30
REG_L EQU 0x31
REZ_L EQU 0x32
REZ_H EQU 0x33
;-------RESET------------------
ORG 0x0000
NOP
NOP
GOTO ZACETEK
ORG 0x0004
PREKENITEV
MOVLW B'10000000'
XORWF PORTC,F
BCF PIR1, TMR1IF
RETFIE
ZACETEK
CALL INIT_IO
CALL INIT_TIMER
CALL INIT_VAR
CALL INIT_IRQ
BSF INTCON,GIE
BSF INTCON,PEIE
CALL INIT_AD
;GLAVNI PROGRAM ------------
_GLAVNA_ZANKA
BSF ADCON0,2
_GLAVNA_ZANKA_1
BTFSC ADCON0,2
goto _GLAVNA_ZANKA_1
CALL RACUN
MOVFW REZ_H
CALL Table
CALL PRIKAZ
MOVFW REZ_H
CALL Table1
CALL PRIKAZ1
;CALL BERI_T2 ;beri tipke
;CALL BERI_T3
;CALL BERI_T4
;CALL OSVEZI_V5 ;reagiraj na tipke
;BTFSS PIR1,CCP1IF ;A je že minilo 10ms?
GOTO _GLAVNA_ZANKA ; ne
CALL OSVEZI_URO ; da, Osveži uro.
BCF PIR1,CCP1IF
MOVF STOTINKE,W ;A je ura xx:xx:xx,50?
SUBLW .50
BTFSC STATUS,Z
CALL SPREMENI_V3 ; da, spremeni V10
MOVF STOTINKE,F ;A je ura xx:xx:xx,00?
BTFSC STATUS,Z
CALL SPREMENI_V3 ; da, spremeni V10
GOTO _GLAVNA_ZANKA
;KONEC GLAVNEGA PROGRAMA ---
;**************************
;podprogrami
RACUN
MOVFW ADRESH
MOVWF REG_L
MOVLW B'00000000'
BSF STATUS,RP0
MOVWF ADRESL
BCF STATUS,RP0
MOVWF REG_H
BCF STATUS,C
RLF REG_L
RLF REG_H
BCF STATUS,C
RLF REG_L
RLF REG_H
BCF STATUS,C
MOVFW ADRESH
ADDWF REG_L,W
MOVWF REZ_L
BSF STATUS,RP0
RLF ADRESL
MOVFW ADRESL
BCF STATUS,RP0
ADDWF REG_H,W
MOVWF REZ_H
BTFSC REZ_L,7
GOTO ZAOKROZI
RETURN
ZAOKROZI
MOVLW B'1'
ADDWF REZ_H,F
RETURN
PRIKAZ
MOVWF TRISB
RETURN
PRIKAZ1
MOVWF TRISC
RETURN
Table
ADDWF PCL,F
RETLW B'11100000'
RETLW B'11111001'
RETLW B'11100100'
RETLW B'11110000'
RETLW B'11111001'
RETLW B'11110010'
Table1
ADDWF PCL,F
RETLW B'11101111'
RETLW B'11111111'
RETLW B'11011111'
RETLW B'11011111'
RETLW B'11001111'
RETLW B'11001111'
OSVEZI_V5
OSVEZI_V5
BTFSC TIPKA,0
CALL PRIZGI_V5
BCF TIPKA,0
BTFSC TIPKA,3
CALL UGASNI_V5
BCF TIPKA,3
RETURN
;OSVEŽEVANJE URE VSAKIH 10ms
OSVEZI_URO
INCF STOTINKE,F
MOVLW .100
SUBWF STOTINKE,W
BTFSS STATUS,C
GOTO _URA_KONEC
CLRF STOTINKE
INCF SEKUNDE,F
MOVLW .60
SUBWF SEKUNDE,W
BTFSS STATUS,C
GOTO _URA_KONEC
CLRF SEKUNDE
INCF MINUTE,F
MOVLW .60
SUBWF MINUTE,W
BTFSS STATUS,C
GOTO _URA_KONEC
CLRF MINUTE
INCF URE,F
MOVLW .24
SUBWF URE,W
BTFSS STATUS,C
GOTO _URA_KONEC
CLRF URE
_URA_KONEC
RETURN
;ZAKASNITEV cca 0.5s
ZAKASNITEV_Z_ZANKO
MOVLW .5
MOVWF ZAK_ST1
_ZAK_1
MOVLW .255
MOVWF ZAK_ST2
_ZAK_2
MOVLW .255
MOVWF ZAK_ST3
_ZAK_3
DECFSZ ZAK_ST3,F
GOTO _ZAK_3
DECFSZ ZAK_ST2,F
GOTO _ZAK_2
DECFSZ ZAK_ST1,F
GOTO _ZAK_1
RETURN
;************************************************
;INICIALIZACIJE
;************************************************
;VHODNO/IZHODNA VRATA
INIT_IO MOVLW 0xFF
MOVWF PORTB
MOVWF PORTC
BSF STATUS,RP0
MOVLW B'11111111' ;TRISx: 1-VHOD
MOVWF TRISA ; 0-IZHOD
MOVLW B'11100000'
MOVWF TRISB
MOVLW B'00000111'
MOVWF TRISC
BCF STATUS,RP0
RETURN
;ÈASOVNIK
INIT_TIMER
MOVLW HIGH(.3125) ;QUARTZ=10MHz, PRESCALLER=8:
MOVWF CCPR1H ; 3125*8*0.4us=10ms
MOVLW LOW(.3125)
MOVWF CCPR1L
MOVLW B'00001011' ;RESETIRAJ TMR1
MOVWF CCP1CON ; pri vrednosti CCPR1
MOVLW B'00110001' ;PREDDELILNIK=8, NOTRANJA URA,
MOVWF T1CON ; VKLOPI ÈASOVNIK
RETURN
;SPREMENLJIVKE
INIT_VAR
MOVLW 0xFF
MOVWF TIP_SS
CLRF TIPKA
RETURN
INIT_IRQ
BSF STATUS,RP0
BCF OPTION_REG, INTEDG
BCF STATUS,RP0
BSF PIE1, TMR1IE
BCF PIR1, TMR1IF
RETURN
INIT_AD
MOVLW B'00001101'
MOVWF ADCON0
BSF STATUS,RP0
MOVLW B'00000000'
MOVFW ADCON1
BCF STATUS,RP0
RETURN
;************************************************
;KONEC
;************************************************
END
|
|
|
Nazaj na vrh |
|
|
gregzy87 Študent
Pridružen/-a: 06.11. 2008, 14:58 Prispevkov: 251 Kraj: Okolica Vrhnike
|
Objavljeno: 24 Feb 2010 22:17 Naslov sporočila: |
|
|
Kaj zaboga je pa to ? Zgleda kot neka ura xx:xx:xx pa neki nastavlaš s tipkami, sam ni mi jasn kaj prpeleš prek AD-ja notr . _________________ Power of dreams (Honda) |
|
Nazaj na vrh |
|
|
|
|
Ne, ne moreš dodajati novih tem v tem forumu Ne, ne moreš odgovarjati na teme v tem forumu Ne, ne moreš urejati svojih prispevkov v tem forumu Ne, ne moreš brisati svojih prispevkov v tem forumu Ne ne moreš glasovati v anketi v tem forumu
|
|