PIC - datum a cas.
Snail Instruments
snail
Středa Březen 17 14:37:28 CET 2004
>Prosim, nepsal nekdo pro PIC kus rutinky, ktera
>prevede datum a cas na pocet minut ? Jiste si to
>mohu napsat, ale pokud by nekdo vedel, kde by se
>to dalo nejlepe v ASM vzit, usetrilo by mi to psani
>(a premysleni) a jen by se to scvrklo na upravu.
Mozna by se hodilo naopak normalizovani casu, porovanavani se pak deje na urovni roku, mesice, dne, hodiny a minuty. Postupuji treba takto:
MOVLW D'20' ;casovy interval
ADDWF WMIN,F
MOVLW WMIN
CALL NRMDT
;ted staci porovnat YEAR a WYEAR, kdyz jsou stejne tak MONTH a WMONTH,... MIN a WMIN.
J. Hanzal
CBLOCK
MIN, HOUR, DAY, MONTH, YEAR
WIN, WHOUR, WDAY, WMONTH, WYEAR
ENDC
; ------------------------------
; DECODE DAYS OF MONTH
; INPUT W - <0,11>
; OUTPUT W - NUMBER OF DAYS
; ------------------------------
DDAYS: ADDLW -D'12'
BTFSC _C
GOTO DDAYS
ADDLW D'12'
ADDWF PCL,F
RETLW D'31'
GOTO DD0
RETLW D'31'
RETLW D'30'
RETLW D'31'
RETLW D'30'
RETLW D'31'
RETLW D'31'
RETLW D'30'
RETLW D'31'
RETLW D'30'
RETLW D'31'
DD0: BTFSS YEAR,0
BTFSC YEAR,1
RETLW D'28'
RETLW D'29'
; ------------------------------
; INCREMENT NEXT DATE & TIME
; ------------------------------
INCNXT: MOVWF INDF
INCF FSR,F
INCF INDF,F
DECF FSR,F
RETURN
; ------------------------------
; NORMALIZE DATE & TIME
; INPUT W - ADDRESS OF TIME VARIABLE
; ------------------------------
NRMDT: MOVWF FSR
NRM2: MOVF INDF,W
ADDLW -D'60'
BTFSS _C
GOTO NRM3
CALL INCNXT
GOTO NRM2
NRM3: INCF FSR,F
NRM4: MOVF INDF,W
ADDLW -D'24'
BTFSS _C
GOTO NRM5
CALL INCNXT
GOTO NRM4
NRM5: INCF FSR,F
NRM6: INCF FSR,F
MOVF INDF,W ;(MOVF MONTH,W)
DECF FSR,F
CALL DDAYS
SUBWF INDF,W
BTFSS _C
GOTO NRM7
CALL INCNXT
GOTO NRM6
NRM7: INCF FSR,F
NRM8: MOVF INDF,W
ADDLW -D'12'
BTFSS _C
GOTO NRM9
CALL INCNXT
GOTO NRM8
NRM9: INCF FSR,F
NRM10: MOVLW D'100'
BTFSC INDF,7
ADDWF INDF,F
MOVF INDF,W
ADDLW -D'100'
BTFSS _C
RETURN
MOVWF INDF
GOTO NRM10
=======================================================================
Laboratory instruments, custom design, GPS modules Laipac
-----------------------------------------------------------------------
Snail Instruments Josef Hanzal, M. S.
Vojanova 615 phone/fax: +420-311-624433
266 01 Beroun e-mail: snail@iol.cz
Czech Republic URL: http://www.vitrum.cz/snail/
GPS: 49deg58'28" North, 14deg 4'35" East
=======================================================================
Další informace o konferenci Hw-list