please dont rip this site

Scenix Contest Aquamon Aq_src.txt

;--------------------------------------------------------------------------------
;--- Title: Aquarium Logger
;--- Date:  05-03-02
;---
;--- By:   Mike Woods
;--- Desc: Reads the temperature and pH from the aquarium and send the values 
;---       out the serial port to a computer.  The PC then updates a Database
;---       where the results can be viewed from a webpage with graphs from 
;---       any date/time.  Eventually I would like to add more features like
;---       Lighting, feeding, etc....
;--------------------------------------------------------------------------------
			;AQ.BAS
			DEVICE	SX28L,TURBO,STACKX_OPTIONX

			FREQ	50000000

;			Equate Section

_OPT 			EQU	$40	;OPTION FUSE
_NCOMP			EQU	$E.0	;_FLAGS._NCOMP
_DLY			EQU	$E.1	;_FLAGS._DLY
_ACK			EQU	$E.2	;_FLAGS._ACK
_TIMO			EQU	$E.3	;_FLAGS._TIMO
_RTS			EQU	$E.4	;_FLAGS._RTS
ADCD1_                  EQU	$7.5
ADCCK1_                 EQU	$7.6
ADCCS1_                 EQU	$7.7
D1W_                    EQU	$7.4
PRESENCE                EQU	$37.0
TX                      EQU	$7.2
_WACC			EQU	$1



;			Data Section

			ORG	$8	;BANK 0

_ACCA               	DS	$2
_ACCB               	DS	$2
_ACCC               	DS	$2
_FLAGS              	DS	$1
_TEMP               	DS	$1
_IPTEN              	DS	$1
_IPTCNT             	DS	$1
_OPTION             	DS	$1
_IPTEDGE            	DS	$1
_RADIR              	DS	$1
_RBDIR              	DS	$1
_RCDIR              	DS	$1
_IPTSAVE            	DS	$7
_PORTA              	DS	$1
_PORTB              	DS	$1

			ORG	$30	;BANK 1

_RX0                	DS	$1
_RX1                	DS	$1
_RX2                	DS	$1
_RX3                	DS	$1
_F1                 	DS	$1	;D1RS_
ADC_DATA            	DS	$1
TEMP_DATA           	DS	$1
X                   	DS	$1
I                   	DS	$1
ADCCNT1_            	DS	$1

;			Code Section

			ORG $0

			;START OF USER CODE

_MAIN
			CALL @__INIT
			
			MOV M,#$0D
			MOV W,#$E0
			MOV !RC,W
			CALL @__DINIT
DINIT
			SETB ADCCS1_
			CLRB ADCCK1_
			MOV M,#$0F
			BANK $12
			CLRB _RCDIR.7
			MOV W,_RCDIR
			MOV !RC,W
			MOV M,#$0F
			CLRB _RCDIR.6
			MOV W,_RCDIR
			MOV !RC,W
			CALL @__CONFIG_D1W_
			RETP
_CONFIG_D1W_
			CALL @__D1RS_
			BANK $34
			MOV W,_F1
			CLRB PRESENCE
			TEST _WACC
			SZ
			SETB PRESENCE
			MOV W,#$CC
			TEST _WACC
			SZ
			SETB D1W_
			SNZ
			CLRB D1W_
			MOV W,#$4E
			TEST _WACC
			SZ
			SETB D1W_
			SNZ
			CLRB D1W_
			MOV W,#$1
			MOV I,W
_X1
			BANK $38
			MOV W,I
			MOV _ACCC,W
			MOV W,#$3
			MOV W,_ACCC-W
			CALL @__GT
			TEST _WACC
			PAGE _X3
			SNZ 
			JMP _X3
			JMP @_X2
_X3
			MOV W,#$7F
			TEST _WACC
			SZ
			SETB D1W_
			SNZ
			CLRB D1W_
			BANK $38
			PAGE _X1
			INCSZ $38
			JMP _X1
_X2
			CALL @__D1RS_
			BANK $34
			MOV W,_F1
			CLRB PRESENCE
			TEST _WACC
			SZ
			SETB PRESENCE
			MOV W,#$CC
			TEST _WACC
			SZ
			SETB D1W_
			SNZ
			CLRB D1W_
			MOV W,#$48
			TEST _WACC
			SZ
			SETB D1W_
			SNZ
			CLRB D1W_
			SETB D1W_
			MOV _ACCA,#$10
			MOV _ACCA+1,#$27
			SETB _DLY
			CALL @_DELAY
			CLRB D1W_
			RETP
_ADC1_
			CLRB ADCCS1_
			MOV W,#$8
			BANK $39
			MOV ADCCNT1_,W
_X4
			CLC
			SNB ADCD1_
			STC
			BANK $35
			RL $35
			SETB ADCCK1_
			MOV W,#$1
			CALL @_DELAYZ
			NOP
			NOP
			NOP
			CLRB ADCCK1_
			NOP
			NOP
			NOP
			NOP
			NOP
			NOP
			PAGE _X4
			DECSZ $39
			JMP _X4
_X5
			NOP
			NOP
			CLC
			SNB ADCD1_
			STC
			BANK $35
			RL $35
			MOV W,#$2
			MOV ADCCNT1_,W
_X8
			SETB ADCCK1_
			MOV W,#$1
			CALL @_DELAYZ
			NOP
			NOP
			NOP
			CLRB ADCCK1_
			MOV W,#$1
			CALL @_DELAYZ
			PAGE _X8
			BANK $39
			DECSZ $39
			JMP _X8
_X9
			SETB ADCCS1_
			RETP
_D1RS_
			CLRB D1W_
			MOV W,#$30
			SETB _DLY
			CALL @_DELAYX
			SETB D1W_
			MOV W,#$6
			SETB _DLY
			CALL @_DELAYX
			BANK $37
			SNB D1W_
			SETB PRESENCE
			SB D1W_
			CLRB PRESENCE
			MOV W,#$2A
			SETB _DLY
			CALL @_DELAYX
			RETP
_TEMP1_
			CALL @__D1RS_
			BANK $34
			MOV W,_F1
			CLRB PRESENCE
			TEST _WACC
			SZ
			SETB PRESENCE
			MOV W,#$CC
			TEST _WACC
			SZ
			SETB D1W_
			SNZ
			CLRB D1W_
			MOV W,#$44
			TEST _WACC
			SZ
			SETB D1W_
			SNZ
			CLRB D1W_
			SETB D1W_
			MOV _ACCA,#$E8
			MOV _ACCA+1,#$FD
			SETB _DLY
			CALL @_DELAY
			MOV _ACCA,#$10
			MOV _ACCA+1,#$27
			SETB _DLY
			CALL @_DELAY
			CLRB D1W_
			MOV W,#$CC
			TEST _WACC
			SZ
			SETB D1W_
			SNZ
			CLRB D1W_
			MOV W,#$8E
			TEST _WACC
			SZ
			SETB D1W_
			SNZ
			CLRB D1W_
			MOV W,#$10
			PAGE _X13
_X13
			CLC
			SNB D1W_
			STC
			RL $36
			DECSZ _WACC
			JMP _X13
			RETP
LOOP1
			CALL @__ADC1_
			CALL @__TEMP1_
			MOV _ACCC,#510&$FF
			MOV _ACCC+1,#510>>8
			BANK $12
			MOV _PORTA,#$FB
			BANK $35
			MOV _ACCB,$35
			MOV FSR,#$7
			CALL @__SEROUTY
			MOV _ACCC,#510&$FF
			MOV _ACCC+1,#510>>8
			BANK $12
			MOV _PORTA,#$FB
			MOV _ACCB,#$7C
			MOV FSR,#$7
			CALL @__SEROUTY
			MOV _ACCC,#510&$FF
			MOV _ACCC+1,#510>>8
			BANK $12
			MOV _PORTA,#$FB
			BANK $36
			MOV _ACCB,$36
			MOV FSR,#$7
			CALL @__SEROUTY
			MOV _ACCC,#510&$FF
			MOV _ACCC+1,#510>>8
			BANK $12
			MOV _PORTA,#$FB
			MOV _ACCB,#$7E
			MOV FSR,#$7
			CALL @__SEROUTY
			MOV W,#$1
			BANK $38
			MOV I,W
_X14
			BANK $38
			MOV W,I
			MOV _ACCC,W
			MOV W,#$A
			MOV W,_ACCC-W
			CALL @__GT
			TEST _WACC
			PAGE _X16
			SNZ 
			JMP _X16
			JMP @_X15
_X16
			MOV _ACCA,#$60
			MOV _ACCA+1,#$EA
			MOV _ACCC,_ACCA
			MOV _ACCC+1,_ACCA+1
			CALL @__WDELAY
			BANK $38
			PAGE _X14
			INCSZ $38
			JMP _X14
_X15
			JMP @LOOP1
;			
;			Copyright @2002 Sxwiz
;			_INIT: COLD START INITIALIZATION
_INIT
			BANK $12
			MOV W,#$FF
			MOV _IPTEN,W
			MOV _IPTEDGE,W
			MOV _RADIR,W
			MOV _RBDIR,W
			MOV _RCDIR,W
			MOV W,#$40
			MOV _OPTION,W
			MOV !OPTION,W
			RETP
;			
;			Copyright @2002 Sxwiz
;			_GT: UNSIGNED RETURN W=$00 (FALSE) IF <=0 ELSE W=$FF (TRUE)
_GT
			MOV W,#0
			SNZ
			RETP
			SC
			RETP
			MOV W,#$FF
			RETP
;			
;			Copyright @2002 Sxwiz
;			ACCC+1:ACCC=1.0 BT+1*200NS, W=DATA, INVERTED START=0
_SEROUTY
			MOV M,#$0F
			MOV _TEMP,#8
			MOV W,_PORTA
			AND IND,W
			CALL @__PORTDC
_SERY1
			MOV _ACCA,_ACCC
			MOV _ACCA+1,_ACCC+1
			CALL @_DELAYY
			RR _ACCB
			PAGE _SERY2
			SNC
			JMP _SERY2
			CALL @__PORTDC
			JMP @_SERY3
_SERY2
			CALL @__PORTDS
_SERY3
			PAGE _SERY1
			DECSZ _TEMP
			JMP _SERY1
			MOV _ACCA,_ACCC
			MOV _ACCA+1,_ACCC+1
			CALL @_DELAYY
			CALL @__PORTDS
			MOV _ACCA,_ACCC
			MOV _ACCA+1,_ACCC+1
			CALL @_DELAYY
			RETP
;			
;			Copyright @2002 Sxwiz
;			PORTDS_: SET PORT DIR INPUT, FSR=PORT, _PORTA=BIT
;			PORTDC_: SET PORT DIR OUTPUT, FSR=PORT, _PORTA=BIT
_PORTDS
			MOV W,#5
			MOV W,FSR-W
			PAGE _PORTDS1
			SNZ
			JMP _PORTDS1
			PAGE _PORTDS2
			DECSZ _WACC
			JMP _PORTDS2
			MOV W,/_PORTA
			OR W,_RBDIR
			MOV _RBDIR,W
			MOV !RB,W
			RETP
_PORTDS1
			MOV W,/_PORTA
			OR W,_RADIR
			MOV _RADIR,W
			MOV !RA,W
			RETP
_PORTDS2
			MOV W,/_PORTA
			OR W,_RCDIR
			MOV _RCDIR,W
			MOV !RC,W
			RETP
_PORTDC
			MOV W,#5
			MOV W,FSR-W
			PAGE _PORTDC1
			SNZ
			JMP _PORTDC1
			PAGE _PORTDC2
			DECSZ _WACC
			JMP _PORTDC2
			MOV W,_PORTA
			AND W,_RBDIR
			MOV _RBDIR,W
			MOV !RB,W
			RETP
_PORTDC1
			MOV W,_PORTA
			AND W,_RADIR
			MOV _RADIR,W
			MOV !RA,W
			RETP
_PORTDC2
			MOV W,_PORTA
			AND W,_RCDIR
			MOV _RCDIR,W
			MOV !RC,W
			RETP
;			
;			Copyright @2002 Sxwiz
;			DELAY 0.1S * _ACCC+1:_ACCC
_WDELAY
			SETB _DLY
_WDELAY1
			MOV _ACCA,#$10
			MOV _ACCA+1,#$27
			CALL @_DELAY
			MOV W,#1
			SUB _ACCC,W
			SC
			SUB _ACCC+1,W
			TEST _ACCC+1
			SNZ
			TEST _ACCC
			SNZ
			RETP
			JMP @_WDELAY1

			;ZERO PAGE CODE


			ORG $200

			PAGE _DELAYZ
			DECSZ _WACC
			JMP _DELAYZ
			RETP
;			
;			Copyright @2002 Sxwiz
;			_DELAYY: DELAY (1+ACCA+1:ACCA)*200NS INCLUDING CALL-RTN
_DELAYY
			MOV W,#1
			NOP
			NOP
			NOP
			NOP
			PAGE _DELAYA
_DELAYA
			SUB _ACCA,W
			SC
			SUB _ACCA+1,W
			TEST _ACCA+1
			SNZ
			TEST _ACCA
			SZ
			JMP _DELAYA
			RETP
;			
;			Copyright @2002 Sxwiz
;			_DELAYX: 1us * W (_DLY CLR)
;			         10us * W (_DLY SET)
;			_DELAY: 1us * _ACCA+1:_ACCA (_DLY CLR)
;			        10us * _ACCA+1:_ACCA (_DLY SET)
_DELAYX
			CLR _ACCA+1
			MOV _ACCA,W
_DELAY
			MOV W,#97
			SB _DLY
			MOV W,#7
_DELAY1
			PAGE _DELAY1
			DECSZ _WACC
			JMP _DELAY1
			CLR !WDT
			MOV W,#1
			SUB _ACCA,W
			SC
			SUB _ACCA+1,W
			TEST _ACCA+1
			SNZ
			TEST _ACCA
			SNZ
			RETP
			JMP @_DELAY
;			
__INIT
			JMP @_INIT
__CONFIG_D1W_
			JMP @_CONFIG_D1W_
__D1RS_
			JMP @_D1RS_
__GT
			JMP @_GT
__ADC1_
			JMP @_ADC1_
__TEMP1_
			JMP @_TEMP1_
__SEROUTY
			JMP @_SEROUTY
__PORTDC
			JMP @_PORTDC
__PORTDS
			JMP @_PORTDS
__WDELAY
			JMP @_WDELAY
;			
;			Copyright @2002 Sxwiz
;			_DELAYZ:  W+1*100NS DELAY (W>0) INCLUDING CALL
_DELAYZ
__DINIT
			JMP @DINIT

			;END OF ZERO PAGE CODE


;			Reset Vector

			ORG $7FF
			JMP _MAIN
			END


file: /Techref/scenix/contest/aquamon/Aq_src.txt, 9KB, , updated: 2002/6/4 10:34, local time: 2024/11/6 03:19,
TOP NEW HELP FIND: 
3.145.100.133:LOG IN
©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://linistepper.com/techref/scenix/contest/aquamon/Aq_src.txt"> scenix contest aquamon Aq_src</A>

Did you find what you needed?