ionutbyly
Membru
Inregistrat: acum 15 ani
Postari: 2
|
|
cine poate modifica acest cod
------------------------------------; CONFIGURATIONBYTE FLAG BYTE ; 7 7 ; 6 6 ; 5 5 I/U CHANGE DONE ; 4 TU OFF/ON 4 I/U TEMP ; 3 TI OFF/ON 3 SPARE OUTPUT ; 2 \ : 00 = OFF 2 U ON/OFF \ ; 1 / : 01 = ON 11 = FLASH 1 I ON/OFF DISPLAYOUTPUT ; 0 0=HHMM 1=MMSS (CALIBRATE) 0 : ON/OFF /
; MODE ; 0x00 : NORMAL TIME DISPLAY ; 0x01 : MAIN MENU SET ; 0x02 : MAIN MENU CONFIG ; ; 0x10 : SET HOUR 10 ; 0x11 : SET HOUR 1 ; 0x12 : SET MINUTE 10 ; 0x13 : SET MINUTE 1 ; ; 0x20 : CONFIG MENU CAL ; 0x21 : ":" CONFIG ; 0x22 : TI OFF/ON ; 0x23 : TU OFF/ON
Radix DEC EXPAND
include "dev_fam.inc" include "p16cxx.inc" ; include "math16.inc"
__CONFIG 09h
CONSTANT I2C_D=0 CONSTANT I2C_C=1 CONSTANT DSPI=0 CONSTANT DSPU=1
_N set 0x19 ; I/O BIT COUNTER IOBYTE set 0x1A ; I/O DATA STORAGE MODE set 0x1B ; DISPLAY/SET MODE FLAGB set 0x1C ; MISC FLAGS FLASH set 0x1D ; TIMER VAR FOR FLASHING DIGITS CONFB set 0x1E ; CONFIGURATION BYTE R0 set 0x1F ; TEMPERATURE LSB R1 set 0x20 ; TEMPERATURE MSB (SIGN) H0 set 0x21 ; HOUR 1 H1 set 0x22 ; HOUR 10 M0 set 0x23 ; MINUTE 1 M1 set 0x24 ; MINUTE 10 S0 set 0x25 ; SECOND 1 S1 set 0x26 ; SECOND 10 HS set 0x27 ; HUNDREDTHS OF A SECOND D0 set 0x28 ; DIGIT DATA LSB D1 set 0x29 ; DIGIT DATA D2 set 0x2A ; DIGIT DATA D3 set 0x2B ; DIGIT DATA MSB T0 set 0x2C ; TEMP STORAGE DELAYLOOPS T1 set 0x2D ; TEMP STORAGE DELAYLOOPS T2 set 0x2E ; TEMP STORAGE DELAYLOOPS T3 set 0x2F ; TEMP STORAGE DELAYLOOPS
;**************************************************************************** ;*** Vectors ;****************************************************************************
ORG 0x00 goto Start ORG 0x04 goto IntVec
;**************************************************************************** ;*** BIN -> LED ;****************************************************************************
B2L: addwf PCL,F retlw b'00111111' ; 0 retlw b'00000110' ; 1 retlw b'01011011' ; 2 retlw b'01001111' ; 3 retlw b'01100110' ; 4 retlw b'01101101' ; 5 retlw b'01111101' ; 6 retlw b'00000111' ; 7 retlw b'01111111' ; 8 retlw b'01101111' ; 9 retlw b'01110110' ; H = 10 retlw b'01111001' ; E = 11 retlw b'00111000' ; L = 12 retlw b'00000100' ; i = 13 retlw b'01010100' ; n = 14 retlw b'01011110' ; d = 15 retlw b'01011100' ; o = 16 retlw b'01010000' ; r = 17 retlw b'00011100' ; u = 18 retlw b'01111000' ; t = 19 retlw b'00000000' ; " " = 20 retlw b'00111001' ; C = 21 retlw b'01110001' ; F = 22 retlw b'01110111' ; A = 23 retlw b'01100011' ; "Degree sign" = 24 retlw b'01000000' ; - = 25
;**************************************************************************** ;*** 500 us delay ;**************************************************************************** ; USES: T0, T1 D500us MOVLW 2 ;1 us MOVWF T0 ;1 us D500us1 MOVLW .80 ;1 us MOVWF T1 ;1 us D500us2 DECFSZ T1,1 ;3 us * 80 * 2 = 480 us GOTO D500us2 DECFSZ T0,1 ;3 us * 2 GOTO D500us1 RETURN ;2 us
;**************************************************************************** ;*** 60 us delay ;**************************************************************************** ; USES: T0
D60us MOVLW .6 MOVWF T0 D60us1 NOP NOP NOP NOP NOP NOP NOP DECFSZ T0, 1 GOTO D60us1 RETURN
;**************************************************************************** ;*** 1 ms delay ;**************************************************************************** ; USES: T0, T1 D1ms MOVLW 2 ;1 us MOVWF T0 ;1 us D1ms1 MOVLW .160 ;1 us MOVWF T1 ;1 us D1ms2 DECFSZ T1,1 ;3 us * 160 * 2 = 960 us GOTO D1ms2 DECFSZ T0,1 ;3 us * 2 GOTO D1ms1 RETURN ;2 us
;**************************************************************************** ;*** "Normal" Delay 500ms ;**************************************************************************** ; USES: (T0),(T1),T2,T3 ; CALL: D500us D500ms MOVLW .20 MOVWF T2 D500ms1 MOVLW 0x0A MOVWF T3 D500ms2 DECFSZ T3,1 GOTO D500ms3 GOTO D500ms4 GOTO D500ms3 D500ms3 CALL D500us CALL D500us GOTO D500ms2 D500ms4 DECFSZ T2,1 GOTO D500ms1 RETURN
;********************************************************************************************************* ;**** BIN2BCD ;********************************************************************************************************* ; USES: _N, T3, (R1,R0)->(T0,T1,T2)
BIN2BCD bcf STATUS,0 movlw .16 movwf _N clrf T0 clrf T1 clrf T2
loop16 rlf R0,1 rlf R1,1 rlf T2,1 rlf T1,1 rlf T0,1 decfsz _N,1 goto adjDEC RETLW 0
adjDEC movlw T2 movwf FSR call BCDADJ movlw T1 movwf FSR call BCDADJ movlw T0 movwf FSR call BCDADJ goto loop16
BCDADJ movlw 3 addwf 0,0 movwf T3 btfsc T3,3 movwf 0 movlw 0x30 addwf 0,0 movwf T3 btfsc T3,7 movwf 0 retlw 0
;********************************************************************************************************* ;**** Initialize ports DDR etc... ;*********************************************************************************************************
PortInit: bsf STATUS,RP0 ; Select Page 1 for TrisB access bcf PORTB,I2C_C bsf PORTB,I2C_D bsf PORTB,7 bsf PORTB,6 bsf PORTB,5 ; bcf OPTREG,7 ; Enable Weak Pullup bcf STATUS,RP0 ; select Page 0 for Port Access bsf PORTB,I2C_C bsf PORTB,I2C_D return
;********************************************************************************************************* ;*** DS COMMUNICATION ;********************************************************************************************************* ; USES: _N, IOBYTE ; CALL: D500us, D60us
DS1: BSF STATUS, RP0 BTFSS FLAGB,4 BSF PORTA, DSPI ; high impedance BTFSC FLAGB,4 BSF PORTA, DSPU BCF STATUS, RP0 RETURN
DS0: BTFSS FLAGB,4 BCF PORTA, DSPI BTFSC FLAGB,4 BCF PORTA, DSPU BSF STATUS, RP0 BTFSS FLAGB,4 BCF PORTA, DSPI BTFSC FLAGB,4 BCF PORTA, DSPU ; low impedance zero BCF STATUS, RP0 RETURN
DSINIT: CALL DS1 CALL DS0 CALL D500us CALL DS1 CALL D500us RETURN
DSWAIT: CALL DSRB MOVLW 0xFF SUBWF IOBYTE, W BTFSS STATUS, Z GOTO DSWAIT RETURN
DSRB: MOVLW .8 MOVWF _N CLRF IOBYTE DSRB1: CALL DS0 ; momentary low on DATA_PIN NOP CALL DS1 NOP NOP NOP NOP NOP NOP MOVF PORTA, W ; 7 usecs later, fetch from DATA_PIN MOVWF T0 BTFSS FLAGB,4 ; I/U? DSRB2 = INNE GOTO DSRB2 BTFSS T0, DSPU ; UTE BCF STATUS, C ; its a zero BTFSC T0, DSPU BSF STATUS, C ; its a one GOTO DSRB3 DSRB2: BTFSS T0, DSPI BCF STATUS, C ; its a zero BTFSC T0, DSPI BSF STATUS, C ; its a one DSRB3: RRF IOBYTE, F CALL D60us DECFSZ _N, F GOTO DSRB1 MOVFW IOBYTE ; return the result in W RETURN
DSWB: MOVWF IOBYTE MOVLW .8 MOVWF _N DSWB1: RRF IOBYTE, F BTFSS STATUS, C GOTO DSWB30 GOTO DSWB31 DSWB2: DECFSZ _N, F GOTO DSWB1 RETURN DSWB30: CALL DS0 ; bring DATA_PIN low CALL D60us CALL DS1 GOTO DSWB2 DSWB31: CALL DS0 ; momentary low CALL DS1 CALL D60us GOTO DSWB2
;********************************************************************************************************* ;*** I2C COMMUNICATION ;********************************************************************************************************* ; USES: _N, IOBYTE ; CALL: D60US, D500US
;*** OUTPUT 1 ON I2C BUS (PIN = INPUT) I2C1: BSF STATUS, RP0 BSF PORTB, I2C_D ; high impedance BCF STATUS, RP0 RETURN
;*** OUTPUT 0 ON I2CBUS I2C0: BCF PORTB, I2C_D BSF STATUS, RP0 BCF PORTB, I2C_D ; low impedance zero BCF STATUS, RP0 BCF PORTB, I2C_D RETURN
;*** SEND I2C START CONDITION I2CSTA: CALL I2C1 CALL D60US BSF PORTB,I2C_C CALL D500US CALL I2C0 CALL D60US BCF PORTB,I2C_C RETURN
;*** SEND I2C STOP CONDITION I2CSTO: CALL I2C0 CALL D60US BSF PORTB,I2C_C CALL D60US CALL I2C1 RETURN
;*** WRITE BYTE TO I2C BUS I2CWB: MOVWF IOBYTE MOVLW .8 MOVWF _N I2CWB1: RLF IOBYTE, F BTFSS STATUS, C GOTO I2CWB3 GOTO I2CWB4 I2CWB2: DECFSZ _N, F GOTO I2CWB1 CALL I2C1 ; read ACK bit... CALL D60US BSF PORTB,I2C_C CALL D60US BCF PORTB,I2C_C CALL D60US RETURN I2CWB3: CALL I2C0 ; bring DATA_PIN low CALL D60US BSF PORTB,I2C_C CALL D60US BCF PORTB,I2C_C GOTO I2CWB2 I2CWB4: CALL I2C1 CALL D60US BSF PORTB,I2C_C CALL D60US BCF PORTB,I2C_C GOTO I2CWB2
;*** READ BYTE FROM I2C BUS I2CRB: CALL I2C1 MOVLW .8 MOVWF _N CLRF IOBYTE I2CRB1: BSF PORTB,I2C_C CALL D60US BSF STATUS,C BTFSS PORTB,I2C_D BCF STATUS,C RLF IOBYTE,F BCF PORTB,I2C_C CALL D60US DECFSZ _N, F GOTO I2CRB1 CALL I2C0 CALL D60US BSF PORTB,I2C_C ; ACK-bit CALL D60US BCF PORTB,I2C_C CALL D60US CALL I2C1 CALL D60US MOVFW IOBYTE ; return the result in W RETURN
;*** READ LAST BYTE FROM I2C BUS (NO ACK) I2CRL: CALL I2C1 MOVLW .8 MOVWF _N CLRF IOBYTE I2CRL1: BSF PORTB,I2C_C CALL D60US BSF STATUS,C BTFSS PORTB,I2C_D BCF STATUS,C RLF IOBYTE,F BCF PORTB,I2C_C CALL D60US DECFSZ _N, F GOTO I2CRL1 CALL I2C0 CALL D60US BSF PORTB,I2C_C ; ACK-bit CALL D60US CALL I2C1 MOVFW IOBYTE ; return the result in W RETURN
;********************************************************************************************************* ;*** DISPLAY DATA IN [D3..D0] ;*********************************************************************************************************
DISP ; SEND DATA TO DISPLAY ; SIFFRA 00:0X CALL I2CSTA MOVLW .64 ; address CALL I2CWB MOVF D0,w CALL B2L CALL I2CWB CALL I2CSTO
; SIFFRA 00:X0 CALL I2CSTA MOVLW .66 ; address CALL I2CWB MOVF D1,w CALL B2L BTFSC FLAGB,0 IORLW 0x80 CALL I2CWB CALL I2CSTO
; SIFFRA 0X:00 CALL I2CSTA MOVLW .68 ; address CALL I2CWB MOVF D2,w CALL B2L BTFSC FLAGB,1 IORLW 0x80 CALL I2CWB CALL I2CSTO
; SIFFRA X0:00 CALL I2CSTA MOVLW .70 ; address CALL I2CWB MOVF D3,w CALL B2L BTFSC FLAGB,2 IORLW 0x80 CALL I2CWB CALL I2CSTO
MOVLW 0xF0 ; RESET :/I/U BITS ANDWF FLAGB,F RETURN
;********************************************************************************************************* ;*** SCROLL "HELLO" ;********************************************************************************************************* HELLO: MOVLW .20 ; " " MOVWF D3 MOVWF D2 MOVWF D1 MOVWF D0 CALL DISP CALL D500ms MOVLW .10 ; " H" MOVWF D0 CALL DISP CALL D500ms MOVF D0,W ; " HE" MOVWF D1 MOVLW .11 MOVWF D0 CALL DISP CALL D500ms MOVF D1,W ; " HEL" MOVWF D2 MOVF D0,W MOVWF D1 MOVLW .12 MOVWF D0 CALL DISP CALL D500ms MOVF D2,W ; "HELL" MOVWF D3 MOVF D1,W MOVWF D2 MOVF D0,W MOVWF D1 MOVLW .12 MOVWF D0 CALL DISP CALL D500ms MOVF D2,W ; "ELLO" MOVWF D3 MOVF D1,W MOVWF D2 MOVF D0,W MOVWF D1 MOVLW .0 MOVWF D0 CALL DISP CALL D500ms MOVF D2,W ; "LLO " MOVWF D3 MOVF D1,W MOVWF D2 MOVF D0,W MOVWF D1 MOVLW .20 MOVWF D0 CALL DISP CALL D500ms MOVF D2,W ; "LO " MOVWF D3 MOVF D1,W MOVWF D2 MOVF D0,W MOVWF D1 MOVLW .20 MOVWF D0 CALL DISP CALL D500ms MOVF D2,W ; "LO " MOVWF D3 MOVF D1,W MOVWF D2 MOVF D0,W MOVWF D1 MOVLW .20 MOVWF D0 CALL DISP CALL D500ms MOVF D2,W ; "O " MOVWF D3 MOVF D1,W MOVWF D2 MOVF D0,W MOVWF D1 MOVLW .20 MOVWF D0 CALL DISP CALL D500ms MOVF D2,W ; " " MOVWF D3 MOVF D1,W MOVWF D2 MOVF D0,W MOVWF D1 MOVLW .20 MOVWF D0 CALL DISP CALL D500ms RETURN
;********************************************************************************************************* ;*** INTERUPT ;********************************************************************************************************* Intvec: BTFSC INTCON,2 INCF FLASH,F BCF INTCON,2 RETFIE
;********************************************************************************************************* ;*** Main Program ;*********************************************************************************************************
Start: bsf STATUS,RP0 CLRWDT ; INITIALIZE T0IE MOVLW 0x07 MOVWF OPTREG bcf STATUS,RP0
BSF INTCON,5 BSF INTCON,7
call PortInit
CLRF MODE CLRF CONFB BSF CONFB,1 ; ":" = ON BSF CONFB,2 ; ":" = FLASHING BSF CONFB,3 ; TI = ON BSF CONFB,4 ; TU = ON
CALL I2CSTO
call D500ms
CALL I2CSTA ; INITIALIZE 8583 CONFIG WORD MOVLW 0xA0 CALL I2CWB MOVLW 0x00 CALL I2CWB MOVLW 0x00 CALL I2CWB CALL I2CSTO
CALL HELLO ; SEND A FANCY WELCOME
LOOP: CALL D1ms ; WAIT FOR A WHILE CALL D1ms CALL D1ms CALL D1ms CALL D1ms
BTFSS PORTB,7 GOTO BMODE BTFSS PORTB,6 GOTO BMINUS BTFSS PORTB,5 GOTO BPLUS GOTO MAIN
BMODE BTFSS PORTB,7 ; DEBOUNCE GOTO BMODE CLRF FLASH INCF MODE,F
MOVF MODE,W SUBLW 0x03 ; MODE=3 -> END OF MENU BTFSC STATUS,Z CLRF MODE
MOVF MODE,W ; MODE=14 -> END OF SET SUBLW 0x14 BTFSS STATUS,Z GOTO BMODE0
CLRF MODE
; STORE TIME TO 8583 CALL I2CSTA MOVLW 0xA0 CALL I2CWB MOVLW 0x02 ; ADRESS SKALL VARA 0x03 F™R TIM/MIN CALL I2CWB MOVLW 0x00 ; SECONDS = 00 CALL I2CWB MOVF M1,W ; MINUTES MOVWF T0 RLF T0,F RLF T0,F RLF T0,F RLF T0,F MOVLW 0xF0 ANDWF T0,F MOVLW 0x0F ANDWF M0,W IORWF T0,W CALL I2CWB MOVF H1,W ; HOURS MOVWF T0 RLF T0,F RLF T0,F RLF T0,F RLF T0,F MOVLW 0xF0 ANDWF T0,F MOVLW 0x0F ANDWF H0,W IORWF T0,W ANDLW 0x3F CALL I2CWB CALL I2CSTO
BMODE0 MOVF MODE,W ; END OF CONFIG MENU SUBLW 0x24 BTFSC STATUS,Z CLRF MODE
BMODEND GOTO MAIN
BMINUS BTFSS PORTB,6 ; DEBOUNCE GOTO BMINUS CLRF FLASH ; X0:00 MOVLW 0x10 SUBWF MODE,W BTFSS STATUS,Z GOTO BM1 MOVLW .2 MOVF H1,F BTFSC STATUS,Z MOVWF H1 BTFSS STATUS,Z DECF H1,F GOTO BMEND BM1 ; 0X:00 MOVLW 0x11 SUBWF MODE,W BTFSS STATUS,Z GOTO BM2 MOVLW .9 MOVF H0,F BTFSC STATUS,Z MOVWF H0 BTFSS STATUS,Z DECF H0,F GOTO BMEND BM2 ; 00:X0 MOVLW 0x12 SUBWF MODE,W BTFSS STATUS,Z GOTO BM3 MOVLW .5 MOVF M1,F BTFSC STATUS,Z MOVWF M1 BTFSS STATUS,Z DECF M1,F GOTO BMEND BM3 ; 00:X0 MOVLW 0x13 SUBWF MODE,W BTFSS STATUS,Z GOTO BM4 MOVLW .9 MOVF M0,F BTFSC STATUS,Z MOVWF M0 BTFSS STATUS,Z DECF M0,F GOTO BMEND BM4 ; CALIBRATION OFF MOVLW 0x20 ; MODE=0x20 -> CAL = OFF SUBWF MODE,W BTFSS STATUS,Z GOTO BM5 BCF CONFB,0 GOTO BMEND BM5 ; : CONFIG MOVLW 0x21 SUBWF MODE,W BTFSS STATUS,Z GOTO BM6 BTFSS CONFB,2 ; 01 -> 00 BCF CONFB,1 BCF CONFB,2 BM6 ; TI CONFIG MOVLW 0x22 SUBWF MODE,W BTFSC STATUS,Z BCF CONFB,3 ; TU CONFIG MOVLW 0x23 SUBWF MODE,W BTFSC STATUS,Z BCF CONFB,4 BMEND GOTO MAIN
BPLUS BTFSS PORTB,5 ; DEBOUNCE GOTO BPLUS CLRF FLASH
MOVLW 0x01 ; MODE=1 -> MODE=0x10 SUBWF MODE,W BTFSS STATUS,Z GOTO BP0
MOVLW 0x10 MOVWF MODE GOTO RTIME ; FIRST READ TIME THEN SET
BP0 ; X0:00 MOVLW 0x10 SUBWF MODE,W BTFSS STATUS,Z GOTO BP1 INCF H1,F MOVLW .3 SUBWF H1,W BTFSS STATUS,Z GOTO BP1 CLRF H1 BP1 ; 0X:00 MOVLW 0x11 SUBWF MODE,W BTFSS STATUS,Z GOTO BP2 INCF H0,F MOVLW .10 SUBWF H0,W BTFSS STATUS,Z GOTO BP2 CLRF H0 BP2 ; 00:X0 MOVLW 0x12 SUBWF MODE,W BTFSS STATUS,Z GOTO BP3 INCF M1,F MOVLW .6 SUBWF M1,W BTFSS STATUS,Z GOTO BP3 CLRF M1 BP3 ; 00:0X MOVLW 0x13 SUBWF MODE,W BTFSS STATUS,Z GOTO BP4 INCF M0,F MOVLW .10 SUBWF M0,W BTFSS STATUS,Z GOTO BP4 CLRF M0 BP4 ; CONF MENU MOVLW 0x02 ; MODE=2 -> MODE=0x20 SUBWF MODE,W BTFSS STATUS,Z GOTO BP5 MOVLW 0x20 MOVWF MODE GOTO BPEND BP5 ; CALIBRATION ON MOVLW 0x20 ; MODE=0x20 -> CAL = ON SUBWF MODE,W BTFSS STATUS,Z GOTO BP6 BSF CONFB,0 GOTO BPEND BP6 ; ":" CONFIG MOVLW 0x21 SUBWF MODE,W BTFSS STATUS,Z GOTO BP7 BTFSC CONFB,1 ; IF ON -> FLASH BSF CONFB,2 BSF CONFB,1 ; BP(+) -> ON BP7 ; TI CONFIG MOVLW 0x22 SUBWF MODE,W BTFSC STATUS,Z BSF CONFB,3 ; TI -> ON ; TU CONFIG MOVLW 0x23 SUBWF MODE,W BTFSC STATUS,Z BSF CONFB,4 ; TI -> ON BPEND GOTO MAIN
;************************************* ; MAIN LOOP! DECIDE WHAT DO DISPLAY!!! ;************************************* MAIN MOVLW 0x01 ; MODE=1 -> DISPLAY "SET" SUBWF MODE,W BTFSC STATUS,Z GOTO DSET MOVLW 0x02 ; MODE=2 -> DISPLAY "CONF" SUBWF MODE,W BTFSC STATUS,Z GOTO DCONF MOVLW 0x20 ; MODE=0x20 -> DISPLAY "CAL " SUBWF MODE,W BTFSC STATUS,Z GOTO DCAL MOVLW 0x21 ; MODE=0x21 -> DISPLAY ": ?" SUBWF MODE,W BTFSC STATUS,Z GOTO DCOL MOVLW 0x22 ; MODE=0x22 -> DISPLAY TIC? SUBWF MODE,W BTFSC STATUS,Z GOTO DTIC MOVLW 0x23 ; MODE=0x22 -> DISPLAY TUC? SUBWF MODE,W BTFSC STATUS,Z GOTO DTUC
MOVF MODE,F ; ONLY IF MODE=0 -> READ TIME BTFSS STATUS,Z ; (DON'T UPDATE TIME WHILE IN MENU!) GOTO DTIME
MOVLW 0x18 ; TI & TU = OFF ANDWF CONFB,W BTFSC STATUS,Z GOTO RTIME
; MAIN CHANGE AT NORMAL RUN BTFSC FLASH,6 ; TIME OR TEMP? GOTO RTEMP GOTO RTIME
RTEMP ; READ TEMP FROM DS1820 AND DISPLAY BTFSC FLAGB,5 ; I->U->I DONE? GOTO RTEMP1 BTFSS FLAGB,4 GOTO RTEMP0 BCF FLAGB,4 GOTO RTEMP1 RTEMP0 BSF FLAGB,4 RTEMP1 BSF FLAGB,5 ; NOW IT'S DONE! ; I OR U DISABLED? BTFSS CONFB,3 ; TI OFF! -> TU BSF FLAGB,4 BTFSS CONFB,4 ; TU OFF! -> TI BCF FLAGB,4 ; SET DISPLAY FLAGS BTFSS FLAGB,4 ; DISPLAY I/U CHARACTER BSF FLAGB,1 BTFSC FLAGB,4 BSF FLAGB,2 ; DO THE ACTUAL READING CALL DSINIT MOVLW 0xCC ; skip ROM CALL DSWB MOVLW 0x44 ; perform temperature conversion CALL DSWB CALL DSWAIT ; wait for conversion to complete CALL DSINIT MOVLW 0xCC ; skip ROM CALL DSWB MOVLW 0xBE ; read scratchpad CALL DSWB CALL DSRB MOVWF R0 CALL DSRB MOVWF R1 CALL DSRB ; Throw away CALL DSRB CALL DSRB CALL DSRB CALL DSRB CALL DSRB CALL DSRB ; IF TEMP<0 -> XOR(R0) MOVLW 0xFF BTFSC R1,0 XORWF R0,F ; DISCARD 1/2 DEGREE BIT BCF STATUS,C RRF R0,F ; INSERT STATIC LETTERS MOVLW .24 ; "DEGREE SIGN" MOVWF D0 MOVLW .20 ; " " BTFSC R1,0 MOVLW .25 ; "-" MOVWF D3 ; NOW CONVERT TO BCD CLRF R1 ; CONTAINS NO DATA CALL BIN2BCD ; STORE NUMBERS MOVF T2,W ; x1 ANDLW 0x0F MOVWF D1 RRF T2,F ; x10 RRF T2,F RRF T2,F RRF T2,W ANDLW 0x0F MOVWF D2 BTFSS STATUS,Z ; DISCARD LEADING ZERO GOTO RTEMP2 MOVF D3,W MOVWF D2 MOVLW .20 MOVWF D3 RTEMP2 ; OK, ALL DONE, DISPLAY TEMP! CALL DISP GOTO LOOP
; READ TIME FROM I2C BUS ; STORE IN H1,H0,M1,M0 RTIME CALL I2CSTA MOVLW 0xA0 ; address CALL I2CWB MOVLW 0x01 ; 01 = HS/SS/MM/HH CALL I2CWB CALL I2CSTO
CALL I2CSTA MOVLW 0xA1 CALL I2CWB CALL I2CRB MOVWF HS CALL I2CRB MOVWF S0 CALL I2CRB MOVWF M0 CALL I2CRL ; READ LAST = NO I2CSTO NEEDED MOVWF H0
; TAKE CARE OF TIME DATA MOVF S0,W MOVWF S1 MOVLW 0x0F ANDWF S0,F RRF S1,F RRF S1,F RRF S1,F RRF S1,F MOVLW 0x0F ANDWF S1,F
MOVF M0,W MOVWF M1 MOVLW 0x0F ANDWF M0,F RRF M1,F RRF M1,F RRF M1,F RRF M1,F MOVLW 0x0F ANDWF M1,F
MOVF H0,W MOVWF H1 MOVLW 0x0F ANDWF H0,F RRF H1,F RRF H1,F RRF H1,F RRF H1,F MOVLW 0x0F ANDWF H1,F
DTIME ; MOVE H1,H0,M1,M0 -> D3,D2,D1,D0 AND FLASH DIGITS ; DIGIT 00:0X BTFSS CONFB,0 MOVF M0,W ; HHMM BTFSC CONFB,0 MOVF S0,W ; MMSS MOVWF D0 BTFSS FLASH,2 GOTO DTIME0 MOVLW 0x13 SUBWF MODE,W BTFSS STATUS,Z GOTO DTIME0 MOVLW .20 MOVWF D0 DTIME0 ; DIGIT 00:X0 BTFSS CONFB,0 MOVF M1,W ; HHMM BTFSC CONFB,0 MOVF S1,W ; MMSS MOVWF D1 BTFSS FLASH,2 GOTO DTIME1 MOVLW 0x12 SUBWF MODE,W BTFSS STATUS,Z GOTO DTIME1 MOVLW .20 MOVWF D1 DTIME1 ; DIGIT 0X:00 BTFSS CONFB,0 MOVF H0,W ; HHMM BTFSC CONFB,0 MOVF M0,W ; MMSS MOVWF D2 BTFSS FLASH,2 GOTO DTIME2 MOVLW 0x11 SUBWF MODE,W BTFSS STATUS,Z GOTO DTIME2 MOVLW .20 MOVWF D2 DTIME2 ; DIGIT X0:00 BTFSS CONFB,0 MOVF H1,W ; HHMM BTFSC CONFB,0 MOVF M1,W ; MMSS MOVWF D3 BTFSS FLASH,2 GOTO DTIME3 MOVLW 0x10 SUBWF MODE,W BTFSS STATUS,Z GOTO DTIME3 MOVLW .20 MOVWF D3 DTIME3 ; ALL DIGITS DONE ; FLASH/DISPLAY COLON BCF FLAGB,0 BTFSS CONFB,1 ; : = OFF GOTO DTIME4 BTFSS CONFB,2 ; : = STEADY/FLASH GOTO DTIME30 BTFSC HS,7 ; 0xxx ? GOTO DTIME4 MOVF HS,W ; 0100 ? ANDLW 0xF0 SUBLW 0x40 BTFSC STATUS,Z GOTO DTIME30 BTFSC HS,6 ; 00xx ? GOTO DTIME4 DTIME30 BSF FLAGB,0 DTIME4 BCF FLAGB,5 ; NEW TEMPCHANGE NEXT TIME! CALL DISP GOTO LOOP
DSET ; DISPLAY "SET " MOVLW .20 ; " " BTFSC FLASH,2 MOVLW .5 ; "S" MOVWF D3 MOVLW .20 ; " " BTFSC FLASH,2 MOVLW .11 ; "E" MOVWF D2 MOVLW .20 ; " " BTFSC FLASH,2 MOVLW .19 ; "T" MOVWF D1 MOVLW .20 ; " " MOVWF D0 CALL DISP GOTO LOOP
DCONF ; DISPLAY "CONF" MOVLW .20 ; " " BTFSC FLASH,2 MOVLW .21 ; "C" MOVWF D3 MOVLW .20 ; " " BTFSC FLASH,2 MOVLW .16 ; "o" MOVWF D2 MOVLW .20 ; " " BTFSC FLASH,2 MOVLW .14 ; "n" MOVWF D1 MOVLW .20 ; " " BTFSC FLASH,2 MOVLW .22 ; "F" MOVWF D0 CALL DISP GOTO LOOP
DCAL ; DISPLAY "CAL" MOVLW .20 ; " " BTFSC FLASH,2 MOVLW .21 ; "C" MOVWF D3 MOVLW .20 ; " " BTFSC FLASH,2 MOVLW .23 ; "A" MOVWF D2 MOVLW .20 ; " " BTFSC FLASH,2 MOVLW .12 ; "L" MOVWF D1 BTFSS CONFB,0 ; IF OFF -> "0" MOVLW .0 BTFSC CONFB,0 ; IF ON -> "1" MOVLW .1 BTFSC FLASH,2 MOVLW .20 ; " " MOVWF D0 CALL DISP GOTO LOOP
DCOL ; DISPLAY : CONFIGURATION BTFSC FLASH,2 BSF FLAGB,0 MOVLW .20 MOVWF D3 MOVWF D2 MOVWF D1 MOVLW .1 ; "1" BTFSC CONFB,2 MOVLW .22 ; "F" BTFSS CONFB,1 MOVLW .0 ; "0" BTFSC FLASH,2 MOVLW .20 ; " " MOVWF D0 CALL DISP GOTO LOOP
DTIC ; DISPLAY TEMP I CONFIGURATION BTFSC FLASH,2 BSF FLAGB,1 MOVLW .20 MOVWF D3 MOVWF D2 MOVWF D1 MOVLW .1 ; "1" BTFSS CONFB,3 MOVLW .0 ; "0" BTFSC FLASH,2 MOVLW .20 ; " " MOVWF D0 CALL DISP GOTO LOOP
DTUC ; DISPLAY TEMP U CONFIGURATION BTFSC FLASH,2 BSF FLAGB,2 MOVLW .20 MOVWF D3 MOVWF D2 MOVWF D1 MOVLW .1 ; "1" BTFSS CONFB,4 MOVLW .0 ; "0" BTFSC FLASH,2 MOVLW .20 ; " " MOVWF D0 CALL DISP GOTO LOOP
END
-===========------==============================
cu mplab ide imi apare urmatoarea eroare
====
Debug build of project `C:\Documents and Settings\ion\My Documents\New Folder\333.mcp' started. Language tool versions: MPASMWIN.exe v5.30.01, mplink.exe v4.30.01 Preprocessor symbol `__DEBUG' is defined. Wed Apr 29 00:08:52 2009 ---------------------------------------------------------------------- Clean: Deleting intermediary and output files. Clean: Done. Executing: "C:\Program Files\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F84A "CLOCK.ASM" /l"CLOCK.lst" /e"CLOCK.err" /d__DEBUG=1 Warning[205] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\DEV_FAM.INC 184 : Found directive in column 1. (MESSG) Message[301] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\DEV_FAM.INC 184 : MESSAGE: (WARNING - USER DEFINED: One and only one device family can be selected) Warning[205] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\DEV_FAM.INC 185 : Found directive in column 1. (MESSG) Message[301] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\DEV_FAM.INC 185 : MESSAGE: ( May be NEW processor not defined in this file) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 78 : Symbol not previously defined (IntVec) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 363 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 365 : Symbol not previously defined (D500US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 367 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 373 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 375 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 390 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 392 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 394 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 397 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 399 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 403 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 405 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 415 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 421 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 425 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 427 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 429 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 431 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 441 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 447 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 451 : Symbol not previously defined (D60US) Error[113] D:\DE TRAS\ELECTRONICA\SCHEME ELECTRONICE\BIG LED-CLOCK - 80X30CM\BIGLEDCLOCKSOURCE\BIGLEDCLOCKSOURCE\CLOCK.ASM 453 : Symbol not previously defined (D60US) Halting build on first failure as requested. ---------------------------------------------------------------------- Debug build of project `C:\Documents and Settings\ion\My Documents\New Folder\333.mcp' failed. Language tool versions: MPASMWIN.exe v5.30.01, mplink.exe v4.30.01 Preprocessor symbol `__DEBUG' is defined. Wed Apr 29 00:08:58 2009 ---------------------------------------------------------------------- BUILD FAILED
NOTA SA FIE DIN ASM IN HEX MULTUMESC
------------------------
|
|