out of variable (help)
Archiver
Posts: 46,084
hi all,
i got the error message "out of variable"
and i think the i need to link my 4K EEPROM memory
chip (24LC32A) with my temperature sensor along with STAMP
i had a problem here as i dunno how to connect the EEPROM memory
chip (24LC32A.
anyone can provide me with the schmematic for the connection?
below is the program.
regards
Ben
Program DS1624.BS2.
This program configures the DS1624 for 1SHOT operation. It then
performs ten temperature measurements and writes the high byte of the
results to sequential locations in EEPROM. It then reads back these
values and displays them on the terminal using the DEBUG command.
' DS1624.BS2
'
' Performs 10 temperature measurements. High bytes are written to
' the first 10 locations in EEPROM. The data is then read from
' EEPROM and displayed using the DEBUG command.
'
' H. Paul Roach, Dec, '97
OUT CON 1
IN CON 0
SDA_OUT VAR OUT8
SCL_OUT VAR OUT9
SDA_IN VAR IN8
SDA_DIR VAR DIR8
SCL_DIR VAR DIR9
T VAR WORD
ADR VAR BYTE
DAT VAR BYTE
O_BYTE VAR BYTE
I_BYTE VAR BYTE
N VAR BYTE
MAIN:
DIRS=$0000 ' start with DIR8 and DIR9 as inputs
GOSUB CONFIG ' configure DS1624 for 1SHOT operation
FOR ADR=0 TO 9 ' make ten measurements
GOSUB INIT ' initiate a conversion
GOSUB MEAS ' fetch the result
DEBUG ?T.BYTE1
DEBUG ?T.BYTE0
DAT = T.BYTE1
GOSUB EE_WRITE ' save high byte to the DS1624 EEPROM
PAUSE 1000
NEXT
FOR ADR=0 TO 9 ' now fetch each from EEPROM and display
GOSUB EE_READ
DAT=I_BYTE
DEBUG ?DAT
NEXT
DONE: GOTO DONE
CONFIG: ' configures DS1624 in 1SHOT temperature conversion mode
GOSUB START
O_BYTE=$94
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=$AC 'Access Config
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=$01 '1 SHOT mode
GOSUB OUT_BYTE
GOSUB NACK
GOSUB SSTOP
PAUSE 30 ' wait for EEPROM to program
RETURN
INIT: ' causes DS1624 to initiate a conversion
GOSUB START
O_BYTE=$94 ' write
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=$EE ' Start Conversion
GOSUB OUT_BYTE
GOSUB NACK
GOSUB SSTOP
PAUSE 1000 ' wait 1000 ms for conversion to complete
RETURN
MEAS: ' fetches temperature result. Value returned in T_HI and
T_LO
GOSUB START
O_BYTE=$94 ' write
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=$AA ' Fetch Temperature
GOSUB OUT_BYTE
GOSUB NACK
GOSUB START ' read
O_BYTE=$95
GOSUB OUT_BYTE
GOSUB NACK
GOSUB IN_BYTE ' fetch the two byte reading
GOSUB ACK ' acknowledge each byte
T.BYTE1 = I_BYTE ' high byte
GOSUB IN_BYTE
GOSUB ACK
T.BYTE0 = I_BYTE
GOSUB SSTOP
RETURN
EE_READ: ' fetches content location ADR in DS1624 EEPROM
' result returned in DAT
GOSUB START
O_BYTE=$94 ' write
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=$17 ' access EEPROM
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=ADR ' specify address to read
DEBUG ?ADR
GOSUB OUT_BYTE
GOSUB NACK
GOSUB START ' now read
O_BYTE=$95
GOSUB OUT_BYTE
GOSUB NACK
GOSUB IN_BYTE
DAT = I_BYTE
GOSUB SSTOP
RETURN
EE_WRITE: ' writes content of DAT to specified address ADR
GOSUB START
O_BYTE=$94 ' write
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=$17 ' Access Memory
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=ADR ' address
'DEBUG ?ADR
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=DAT ' data to write
'DEBUG HEX2 ?DAT
GOSUB OUT_BYTE
GOSUB NACK
GOSUB SSTOP
PAUSE 15 ' wait for EEPROM to program
RETURN
OUT_BYTE: ' sends content of O_BYTE, most sig byte first
FOR N=7 to 0
BRANCH (O_BYTE>>N)&$01, [noparse][[/noparse]OUT_0, OUT_1]
OUT_0:
GOSUB LO_SDA
'DEBUG "0"
GOTO OUT_BYTE_1
OUT_1:
GOSUB HI_SDA
'DEBUG "1"
GOTO OUT_BYTE_1
OUT_BYTE_1:
GOSUB CLK
GOSUB HI_SDA
NEXT
'DEBUG CR
RETURN
IN_BYTE: ' receives a byte, most sig byte first.
' result returned in I_BYTE
GOSUB HI_SDA
I_BYTE=0
FOR N=0 TO 7
GOSUB HI_SCL
I_BYTE= (I_BYTE<<1) | SDA_IN
DEBUG DEC SDA_IN
GOSUB LO_SCL
NEXT
DEBUG CR
RETURN
NACK: ' clock pulse while SDA in high impdeance to allow
' slave to acknowledge by bringing SDA low
GOSUB HI_SDA
GOSUB CLK
RETURN
ACK: ' clock pulse while SDA low to acknowledge receipt of
' a byte from the slave
GOSUB LO_SDA
GOSUB CLK
GOSUB HI_SDA
RETURN
CLK: ' momentarily bring SCL high
GOSUB HI_SCL
GOSUB LO_SCL
RETURN
START: ' bring SDA from high to low while SCL is high
GOSUB LO_SCL
GOSUB HI_SDA
GOSUB HI_SCL
GOSUB LO_SDA 'SDA transition to low when SCL high
GOSUB LO_SCL
RETURN
SSTOP: ' bring SDA from low to high while SCL is high
GOSUB LO_SCL
GOSUB LO_SDA 'be sure SDA is in low state
GOSUB HI_SCL
GOSUB HI_SDA 'SDA transition to high when SCL is high
RETURN 'both SDA and SCL left in high-Z
LO_SDA:
SDA_OUT=0
SDA_DIR=OUT
RETURN
LO_SCL:
SCL_OUT=0
SCL_DIR=OUT
RETURN
HI_SDA:
SDA_DIR=IN
RETURN
HI_SCL:
SCL_DIR=IN
RETURN
i got the error message "out of variable"
and i think the i need to link my 4K EEPROM memory
chip (24LC32A) with my temperature sensor along with STAMP
i had a problem here as i dunno how to connect the EEPROM memory
chip (24LC32A.
anyone can provide me with the schmematic for the connection?
below is the program.
regards
Ben
Program DS1624.BS2.
This program configures the DS1624 for 1SHOT operation. It then
performs ten temperature measurements and writes the high byte of the
results to sequential locations in EEPROM. It then reads back these
values and displays them on the terminal using the DEBUG command.
' DS1624.BS2
'
' Performs 10 temperature measurements. High bytes are written to
' the first 10 locations in EEPROM. The data is then read from
' EEPROM and displayed using the DEBUG command.
'
' H. Paul Roach, Dec, '97
OUT CON 1
IN CON 0
SDA_OUT VAR OUT8
SCL_OUT VAR OUT9
SDA_IN VAR IN8
SDA_DIR VAR DIR8
SCL_DIR VAR DIR9
T VAR WORD
ADR VAR BYTE
DAT VAR BYTE
O_BYTE VAR BYTE
I_BYTE VAR BYTE
N VAR BYTE
MAIN:
DIRS=$0000 ' start with DIR8 and DIR9 as inputs
GOSUB CONFIG ' configure DS1624 for 1SHOT operation
FOR ADR=0 TO 9 ' make ten measurements
GOSUB INIT ' initiate a conversion
GOSUB MEAS ' fetch the result
DEBUG ?T.BYTE1
DEBUG ?T.BYTE0
DAT = T.BYTE1
GOSUB EE_WRITE ' save high byte to the DS1624 EEPROM
PAUSE 1000
NEXT
FOR ADR=0 TO 9 ' now fetch each from EEPROM and display
GOSUB EE_READ
DAT=I_BYTE
DEBUG ?DAT
NEXT
DONE: GOTO DONE
CONFIG: ' configures DS1624 in 1SHOT temperature conversion mode
GOSUB START
O_BYTE=$94
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=$AC 'Access Config
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=$01 '1 SHOT mode
GOSUB OUT_BYTE
GOSUB NACK
GOSUB SSTOP
PAUSE 30 ' wait for EEPROM to program
RETURN
INIT: ' causes DS1624 to initiate a conversion
GOSUB START
O_BYTE=$94 ' write
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=$EE ' Start Conversion
GOSUB OUT_BYTE
GOSUB NACK
GOSUB SSTOP
PAUSE 1000 ' wait 1000 ms for conversion to complete
RETURN
MEAS: ' fetches temperature result. Value returned in T_HI and
T_LO
GOSUB START
O_BYTE=$94 ' write
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=$AA ' Fetch Temperature
GOSUB OUT_BYTE
GOSUB NACK
GOSUB START ' read
O_BYTE=$95
GOSUB OUT_BYTE
GOSUB NACK
GOSUB IN_BYTE ' fetch the two byte reading
GOSUB ACK ' acknowledge each byte
T.BYTE1 = I_BYTE ' high byte
GOSUB IN_BYTE
GOSUB ACK
T.BYTE0 = I_BYTE
GOSUB SSTOP
RETURN
EE_READ: ' fetches content location ADR in DS1624 EEPROM
' result returned in DAT
GOSUB START
O_BYTE=$94 ' write
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=$17 ' access EEPROM
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=ADR ' specify address to read
DEBUG ?ADR
GOSUB OUT_BYTE
GOSUB NACK
GOSUB START ' now read
O_BYTE=$95
GOSUB OUT_BYTE
GOSUB NACK
GOSUB IN_BYTE
DAT = I_BYTE
GOSUB SSTOP
RETURN
EE_WRITE: ' writes content of DAT to specified address ADR
GOSUB START
O_BYTE=$94 ' write
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=$17 ' Access Memory
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=ADR ' address
'DEBUG ?ADR
GOSUB OUT_BYTE
GOSUB NACK
O_BYTE=DAT ' data to write
'DEBUG HEX2 ?DAT
GOSUB OUT_BYTE
GOSUB NACK
GOSUB SSTOP
PAUSE 15 ' wait for EEPROM to program
RETURN
OUT_BYTE: ' sends content of O_BYTE, most sig byte first
FOR N=7 to 0
BRANCH (O_BYTE>>N)&$01, [noparse][[/noparse]OUT_0, OUT_1]
OUT_0:
GOSUB LO_SDA
'DEBUG "0"
GOTO OUT_BYTE_1
OUT_1:
GOSUB HI_SDA
'DEBUG "1"
GOTO OUT_BYTE_1
OUT_BYTE_1:
GOSUB CLK
GOSUB HI_SDA
NEXT
'DEBUG CR
RETURN
IN_BYTE: ' receives a byte, most sig byte first.
' result returned in I_BYTE
GOSUB HI_SDA
I_BYTE=0
FOR N=0 TO 7
GOSUB HI_SCL
I_BYTE= (I_BYTE<<1) | SDA_IN
DEBUG DEC SDA_IN
GOSUB LO_SCL
NEXT
DEBUG CR
RETURN
NACK: ' clock pulse while SDA in high impdeance to allow
' slave to acknowledge by bringing SDA low
GOSUB HI_SDA
GOSUB CLK
RETURN
ACK: ' clock pulse while SDA low to acknowledge receipt of
' a byte from the slave
GOSUB LO_SDA
GOSUB CLK
GOSUB HI_SDA
RETURN
CLK: ' momentarily bring SCL high
GOSUB HI_SCL
GOSUB LO_SCL
RETURN
START: ' bring SDA from high to low while SCL is high
GOSUB LO_SCL
GOSUB HI_SDA
GOSUB HI_SCL
GOSUB LO_SDA 'SDA transition to low when SCL high
GOSUB LO_SCL
RETURN
SSTOP: ' bring SDA from low to high while SCL is high
GOSUB LO_SCL
GOSUB LO_SDA 'be sure SDA is in low state
GOSUB HI_SCL
GOSUB HI_SDA 'SDA transition to high when SCL is high
RETURN 'both SDA and SCL left in high-Z
LO_SDA:
SDA_OUT=0
SDA_DIR=OUT
RETURN
LO_SCL:
SCL_OUT=0
SCL_DIR=OUT
RETURN
HI_SDA:
SDA_DIR=IN
RETURN
HI_SCL:
SCL_DIR=IN
RETURN
Comments
You could free up a lot of variable space in the program below by "hard
coding" a bunch of the variables. For example, wherever the the CONs "OUT"
or "IN" are used in the program, you could change it to "1" or "0".
Sorry, I've never used that eeprom before, and I *think* you would still
need vars in the program to use data from the eeprom in the program. I may
have that wrong though, as I said, I've never done it.
Jonathan
www.madlabs.info
Original Message
From: "benzlim83" <benzlim83@y...>
To: <basicstamps@yahoogroups.com>
Sent: Friday, November 28, 2003 10:00 AM
Subject: [noparse][[/noparse]basicstamps] out of variable (help)
> hi all,
>
> i got the error message "out of variable"
>
> and i think the i need to link my 4K EEPROM memory
> chip (24LC32A) with my temperature sensor along with STAMP
>
> i had a problem here as i dunno how to connect the EEPROM memory
> chip (24LC32A.
>
> anyone can provide me with the schmematic for the connection?
> below is the program.
>
> regards
> Ben
>
>
>
> Program DS1624.BS2.
>
> This program configures the DS1624 for 1SHOT operation. It then
> performs ten temperature measurements and writes the high byte of the
> results to sequential locations in EEPROM. It then reads back these
> values and displays them on the terminal using the DEBUG command.
>
> ' DS1624.BS2
> '
> ' Performs 10 temperature measurements. High bytes are written to
> ' the first 10 locations in EEPROM. The data is then read from
> ' EEPROM and displayed using the DEBUG command.
> '
> ' H. Paul Roach, Dec, '97
>
> OUT CON 1
> IN CON 0
>
> SDA_OUT VAR OUT8
> SCL_OUT VAR OUT9
>
> SDA_IN VAR IN8
>
> SDA_DIR VAR DIR8
> SCL_DIR VAR DIR9
>
> T VAR WORD
> ADR VAR BYTE
> DAT VAR BYTE
>
> O_BYTE VAR BYTE
> I_BYTE VAR BYTE
> N VAR BYTE
>
> MAIN:
> DIRS=$0000 ' start with DIR8 and DIR9 as inputs
>
> GOSUB CONFIG ' configure DS1624 for 1SHOT operation
>
> FOR ADR=0 TO 9 ' make ten measurements
> GOSUB INIT ' initiate a conversion
> GOSUB MEAS ' fetch the result
> DEBUG ?T.BYTE1
> DEBUG ?T.BYTE0
> DAT = T.BYTE1
> GOSUB EE_WRITE ' save high byte to the DS1624 EEPROM
> PAUSE 1000
> NEXT
>
> FOR ADR=0 TO 9 ' now fetch each from EEPROM and display
> GOSUB EE_READ
> DAT=I_BYTE
> DEBUG ?DAT
> NEXT
>
> DONE: GOTO DONE
>
> CONFIG: ' configures DS1624 in 1SHOT temperature conversion mode
> GOSUB START
>
> O_BYTE=$94
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=$AC 'Access Config
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=$01 '1 SHOT mode
> GOSUB OUT_BYTE
> GOSUB NACK
>
> GOSUB SSTOP
> PAUSE 30 ' wait for EEPROM to program
>
> RETURN
>
> INIT: ' causes DS1624 to initiate a conversion
> GOSUB START
>
> O_BYTE=$94 ' write
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=$EE ' Start Conversion
> GOSUB OUT_BYTE
> GOSUB NACK
>
> GOSUB SSTOP
> PAUSE 1000 ' wait 1000 ms for conversion to complete
>
> RETURN
>
> MEAS: ' fetches temperature result. Value returned in T_HI and
> T_LO
> GOSUB START
> O_BYTE=$94 ' write
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=$AA ' Fetch Temperature
> GOSUB OUT_BYTE
> GOSUB NACK
>
> GOSUB START ' read
> O_BYTE=$95
> GOSUB OUT_BYTE
> GOSUB NACK
>
> GOSUB IN_BYTE ' fetch the two byte reading
> GOSUB ACK ' acknowledge each byte
> T.BYTE1 = I_BYTE ' high byte
>
> GOSUB IN_BYTE
> GOSUB ACK
> T.BYTE0 = I_BYTE
>
> GOSUB SSTOP
>
> RETURN
>
> EE_READ: ' fetches content location ADR in DS1624 EEPROM
> ' result returned in DAT
> GOSUB START
>
> O_BYTE=$94 ' write
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=$17 ' access EEPROM
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=ADR ' specify address to read
> DEBUG ?ADR
> GOSUB OUT_BYTE
> GOSUB NACK
>
> GOSUB START ' now read
> O_BYTE=$95
> GOSUB OUT_BYTE
> GOSUB NACK
>
> GOSUB IN_BYTE
> DAT = I_BYTE
>
> GOSUB SSTOP
>
> RETURN
>
> EE_WRITE: ' writes content of DAT to specified address ADR
> GOSUB START
>
> O_BYTE=$94 ' write
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=$17 ' Access Memory
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=ADR ' address
> 'DEBUG ?ADR
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=DAT ' data to write
> 'DEBUG HEX2 ?DAT
> GOSUB OUT_BYTE
> GOSUB NACK
> GOSUB SSTOP
> PAUSE 15 ' wait for EEPROM to program
>
> RETURN
>
> OUT_BYTE: ' sends content of O_BYTE, most sig byte first
> FOR N=7 to 0
> BRANCH (O_BYTE>>N)&$01, [noparse][[/noparse]OUT_0, OUT_1]
> OUT_0:
> GOSUB LO_SDA
> 'DEBUG "0"
> GOTO OUT_BYTE_1
>
> OUT_1:
> GOSUB HI_SDA
> 'DEBUG "1"
> GOTO OUT_BYTE_1
>
> OUT_BYTE_1:
> GOSUB CLK
> GOSUB HI_SDA
> NEXT
> 'DEBUG CR
> RETURN
>
> IN_BYTE: ' receives a byte, most sig byte first.
> ' result returned in I_BYTE
> GOSUB HI_SDA
> I_BYTE=0
> FOR N=0 TO 7
> GOSUB HI_SCL
> I_BYTE= (I_BYTE<<1) | SDA_IN
> DEBUG DEC SDA_IN
> GOSUB LO_SCL
> NEXT
> DEBUG CR
> RETURN
>
> NACK: ' clock pulse while SDA in high impdeance to allow
> ' slave to acknowledge by bringing SDA low
> GOSUB HI_SDA
> GOSUB CLK
> RETURN
>
> ACK: ' clock pulse while SDA low to acknowledge receipt of
> ' a byte from the slave
> GOSUB LO_SDA
> GOSUB CLK
> GOSUB HI_SDA
> RETURN
>
> CLK: ' momentarily bring SCL high
> GOSUB HI_SCL
> GOSUB LO_SCL
> RETURN
>
> START: ' bring SDA from high to low while SCL is high
> GOSUB LO_SCL
> GOSUB HI_SDA
> GOSUB HI_SCL
> GOSUB LO_SDA 'SDA transition to low when SCL high
> GOSUB LO_SCL
> RETURN
>
> SSTOP: ' bring SDA from low to high while SCL is high
> GOSUB LO_SCL
> GOSUB LO_SDA 'be sure SDA is in low state
> GOSUB HI_SCL
> GOSUB HI_SDA 'SDA transition to high when SCL is high
> RETURN 'both SDA and SCL left in high-Z
>
> LO_SDA:
> SDA_OUT=0
> SDA_DIR=OUT
> RETURN
>
> LO_SCL:
> SCL_OUT=0
> SCL_DIR=OUT
> RETURN
>
> HI_SDA:
> SDA_DIR=IN
> RETURN
>
> HI_SCL:
> SCL_DIR=IN
> RETURN
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
>Ben,
>
>You could free up a lot of variable space in the program below by "hard
>coding" a bunch of the variables. For example, wherever the the CONs "OUT"
>or "IN" are used in the program, you could change it to "1" or "0".
>
>Sorry, I've never used that eeprom before, and I *think* you would still
>need vars in the program to use data from the eeprom in the program. I may
>have that wrong though, as I said, I've never done it.
>
>Jonathan
>
>www.madlabs.info
Just to keep the record straight only VARS take up variable space. CONS can
be used as you wish with no memory penalty. CONS can actually improve the
readabilty of programs.
Bruce Bates
>
> Just to keep the record straight only VARS take up variable space. CONS
can
> be used as you wish with no memory penalty. CONS can actually improve the
> readabilty of programs.
Thanks for the correction. I thought CONs did take memory space.
Jonathan
what do u mean by "hard coding" a bunch of the variables?
regards
Ben
Jonathan Peakall <jpeakall@p...> wrote:
Ben,
You could free up a lot of variable space in the program below by "hard
coding" a bunch of the variables. For example, wherever the the CONs "OUT"
or "IN" are used in the program, you could change it to "1" or "0".
Sorry, I've never used that eeprom before, and I *think* you would still
need vars in the program to use data from the eeprom in the program. I may
have that wrong though, as I said, I've never done it.
Jonathan
www.madlabs.info
Original Message
From: "benzlim83"
To:
Sent: Friday, November 28, 2003 10:00 AM
Subject: [noparse][[/noparse]basicstamps] out of variable (help)
> hi all,
>
> i got the error message "out of variable"
>
> and i think the i need to link my 4K EEPROM memory
> chip (24LC32A) with my temperature sensor along with STAMP
>
> i had a problem here as i dunno how to connect the EEPROM memory
> chip (24LC32A.
>
> anyone can provide me with the schmematic for the connection?
> below is the program.
>
> regards
> Ben
>
>
>
> Program DS1624.BS2.
>
> This program configures the DS1624 for 1SHOT operation. It then
> performs ten temperature measurements and writes the high byte of the
> results to sequential locations in EEPROM. It then reads back these
> values and displays them on the terminal using the DEBUG command.
>
> ' DS1624.BS2
> '
> ' Performs 10 temperature measurements. High bytes are written to
> ' the first 10 locations in EEPROM. The data is then read from
> ' EEPROM and displayed using the DEBUG command.
> '
> ' H. Paul Roach, Dec, '97
>
> OUT CON 1
> IN CON 0
>
> SDA_OUT VAR OUT8
> SCL_OUT VAR OUT9
>
> SDA_IN VAR IN8
>
> SDA_DIR VAR DIR8
> SCL_DIR VAR DIR9
>
> T VAR WORD
> ADR VAR BYTE
> DAT VAR BYTE
>
> O_BYTE VAR BYTE
> I_BYTE VAR BYTE
> N VAR BYTE
>
> MAIN:
> DIRS=$0000 ' start with DIR8 and DIR9 as inputs
>
> GOSUB CONFIG ' configure DS1624 for 1SHOT operation
>
> FOR ADR=0 TO 9 ' make ten measurements
> GOSUB INIT ' initiate a conversion
> GOSUB MEAS ' fetch the result
> DEBUG ?T.BYTE1
> DEBUG ?T.BYTE0
> DAT = T.BYTE1
> GOSUB EE_WRITE ' save high byte to the DS1624 EEPROM
> PAUSE 1000
> NEXT
>
> FOR ADR=0 TO 9 ' now fetch each from EEPROM and display
> GOSUB EE_READ
> DAT=I_BYTE
> DEBUG ?DAT
> NEXT
>
> DONE: GOTO DONE
>
> CONFIG: ' configures DS1624 in 1SHOT temperature conversion mode
> GOSUB START
>
> O_BYTE=$94
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=$AC 'Access Config
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=$01 '1 SHOT mode
> GOSUB OUT_BYTE
> GOSUB NACK
>
> GOSUB SSTOP
> PAUSE 30 ' wait for EEPROM to program
>
> RETURN
>
> INIT: ' causes DS1624 to initiate a conversion
> GOSUB START
>
> O_BYTE=$94 ' write
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=$EE ' Start Conversion
> GOSUB OUT_BYTE
> GOSUB NACK
>
> GOSUB SSTOP
> PAUSE 1000 ' wait 1000 ms for conversion to complete
>
> RETURN
>
> MEAS: ' fetches temperature result. Value returned in T_HI and
> T_LO
> GOSUB START
> O_BYTE=$94 ' write
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=$AA ' Fetch Temperature
> GOSUB OUT_BYTE
> GOSUB NACK
>
> GOSUB START ' read
> O_BYTE=$95
> GOSUB OUT_BYTE
> GOSUB NACK
>
> GOSUB IN_BYTE ' fetch the two byte reading
> GOSUB ACK ' acknowledge each byte
> T.BYTE1 = I_BYTE ' high byte
>
> GOSUB IN_BYTE
> GOSUB ACK
> T.BYTE0 = I_BYTE
>
> GOSUB SSTOP
>
> RETURN
>
> EE_READ: ' fetches content location ADR in DS1624 EEPROM
> ' result returned in DAT
> GOSUB START
>
> O_BYTE=$94 ' write
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=$17 ' access EEPROM
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=ADR ' specify address to read
> DEBUG ?ADR
> GOSUB OUT_BYTE
> GOSUB NACK
>
> GOSUB START ' now read
> O_BYTE=$95
> GOSUB OUT_BYTE
> GOSUB NACK
>
> GOSUB IN_BYTE
> DAT = I_BYTE
>
> GOSUB SSTOP
>
> RETURN
>
> EE_WRITE: ' writes content of DAT to specified address ADR
> GOSUB START
>
> O_BYTE=$94 ' write
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=$17 ' Access Memory
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=ADR ' address
> 'DEBUG ?ADR
> GOSUB OUT_BYTE
> GOSUB NACK
>
> O_BYTE=DAT ' data to write
> 'DEBUG HEX2 ?DAT
> GOSUB OUT_BYTE
> GOSUB NACK
> GOSUB SSTOP
> PAUSE 15 ' wait for EEPROM to program
>
> RETURN
>
> OUT_BYTE: ' sends content of O_BYTE, most sig byte first
> FOR N=7 to 0
> BRANCH (O_BYTE>>N)&$01, [noparse][[/noparse]OUT_0, OUT_1]
> OUT_0:
> GOSUB LO_SDA
> 'DEBUG "0"
> GOTO OUT_BYTE_1
>
> OUT_1:
> GOSUB HI_SDA
> 'DEBUG "1"
> GOTO OUT_BYTE_1
>
> OUT_BYTE_1:
> GOSUB CLK
> GOSUB HI_SDA
> NEXT
> 'DEBUG CR
> RETURN
>
> IN_BYTE: ' receives a byte, most sig byte first.
> ' result returned in I_BYTE
> GOSUB HI_SDA
> I_BYTE=0
> FOR N=0 TO 7
> GOSUB HI_SCL
> I_BYTE= (I_BYTE<<1) | SDA_IN
> DEBUG DEC SDA_IN
> GOSUB LO_SCL
> NEXT
> DEBUG CR
> RETURN
>
> NACK: ' clock pulse while SDA in high impdeance to allow
> ' slave to acknowledge by bringing SDA low
> GOSUB HI_SDA
> GOSUB CLK
> RETURN
>
> ACK: ' clock pulse while SDA low to acknowledge receipt of
> ' a byte from the slave
> GOSUB LO_SDA
> GOSUB CLK
> GOSUB HI_SDA
> RETURN
>
> CLK: ' momentarily bring SCL high
> GOSUB HI_SCL
> GOSUB LO_SCL
> RETURN
>
> START: ' bring SDA from high to low while SCL is high
> GOSUB LO_SCL
> GOSUB HI_SDA
> GOSUB HI_SCL
> GOSUB LO_SDA 'SDA transition to low when SCL high
> GOSUB LO_SCL
> RETURN
>
> SSTOP: ' bring SDA from low to high while SCL is high
> GOSUB LO_SCL
> GOSUB LO_SDA 'be sure SDA is in low state
> GOSUB HI_SCL
> GOSUB HI_SDA 'SDA transition to high when SCL is high
> RETURN 'both SDA and SCL left in high-Z
>
> LO_SDA:
> SDA_OUT=0
> SDA_DIR=OUT
> RETURN
>
> LO_SCL:
> SCL_OUT=0
> SCL_DIR=OUT
> RETURN
>
> HI_SDA:
> SDA_DIR=IN
> RETURN
>
> HI_SCL:
> SCL_DIR=IN
> RETURN
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and Body of
the message will be ignored.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
[noparse][[/noparse]Non-text portions of this message have been removed]
For example:
Serial_Out VAR BYTE
baud VAR byte
Serial_Out = 0
baud = 17197
Main:
serout serial_out,baud, [noparse][[/noparse]"Hello World"]
goto main
Would send the "Hello World" string to a serial device, like an LCD. People
often write the code like this so they can easily change the pin that the
serial data goes out on, and the baud rate. But, if you want, you can
"hardcode" the variables, like this:
main:
serout 0,17197,[noparse][[/noparse]"Hello World"]
goto main
However, as Bruce just pointed out, CONs don't use variable space (I didn't
realize this) you could write:
Serial_Out CON 0
baud CON 19197
Main:
serout serial_out,baud, [noparse][[/noparse]"Hello World"]
goto main
Of course, this only works if the number can remain the same during the
program, but the same applies to hardcoding.
I don't have time this AM to look at your code in detail, but it does seems
as if there should be plenty of variable space left. Is this the complete
program? If not, send us the complete code. A quick look at the program
shows it won't save a lot of room to hardcode some vars, so thet idea won't
really help, but there are other ways.
Also, you can use a different slot. As you probably know, the BS2s all have
8 program slots. You can drop the DS1624 code in one slot and your main
program in another. Then, call the slot with the DS1624 from your main
program. There are some good docs on the Parallax site about the use of
slots.
Hope this helps,
Jonathan
www.madlabs.info
As u have bring up abt the 8 program slots, how would i drop the DS1624 code in
one slot and your main program in another. Is there any command for it?
Regards
Ben
Jonathan Peakall <jpeakall@p...> wrote:
Ben,
For example:
Serial_Out VAR BYTE
baud VAR byte
Serial_Out = 0
baud = 17197
Main:
serout serial_out,baud, [noparse][[/noparse]"Hello World"]
goto main
Would send the "Hello World" string to a serial device, like an LCD. People
often write the code like this so they can easily change the pin that the
serial data goes out on, and the baud rate. But, if you want, you can
"hardcode" the variables, like this:
main:
serout 0,17197,[noparse][[/noparse]"Hello World"]
goto main
However, as Bruce just pointed out, CONs don't use variable space (I didn't
realize this) you could write:
Serial_Out CON 0
baud CON 19197
Main:
serout serial_out,baud, [noparse][[/noparse]"Hello World"]
goto main
Of course, this only works if the number can remain the same during the
program, but the same applies to hardcoding.
I don't have time this AM to look at your code in detail, but it does seems
as if there should be plenty of variable space left. Is this the complete
program? If not, send us the complete code. A quick look at the program
shows it won't save a lot of room to hardcode some vars, so thet idea won't
really help, but there are other ways.
Also, you can use a different slot. As you probably know, the BS2s all have
8 program slots. You can drop the DS1624 code in one slot and your main
program in another. Then, call the slot with the DS1624 from your main
program. There are some good docs on the Parallax site about the use of
slots.
Hope this helps,
Jonathan
www.madlabs.info
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and Body of
the message will be ignored.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
[noparse][[/noparse]Non-text portions of this message have been removed]
> As u have bring up abt the 8 program slots, how would i drop the DS1624
code in one slot and your main program in another. Is there any command for
it?
>
You use the "RUN" command. Look on the Parallax site and in the Stampworks
docs for details. Search for "multi-bank programming". It's a minor PITA to
figure it out, but not too bad.
Like I said earlier though, it looks like you have lots of room for vars
left in that program. Is that the complete program?
Jonathan
l'm doing a school project so my program will not be complete so soon, i will
add other stuff into it too.
Ben
Jonathan Peakall <jpeakall@p...> wrote:
Ben,
> As u have bring up abt the 8 program slots, how would i drop the DS1624
code in one slot and your main program in another. Is there any command for
it?
>
You use the "RUN" command. Look on the Parallax site and in the Stampworks
docs for details. Search for "multi-bank programming". It's a minor PITA to
figure it out, but not too bad.
Like I said earlier though, it looks like you have lots of room for vars
left in that program. Is that the complete program?
Jonathan
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and Body of
the message will be ignored.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
[noparse][[/noparse]Non-text portions of this message have been removed]
will give you a workable strategy for calling accessory routines in
extra slots from the main program slot.
http://www.parallax.com/dl/docs/cols/nv/vol3/col/87.pdf
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: lim EngTat [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=ItpYhLMB2LBVz4LFH2jxemfXDDCI7eN9dbCiFkoPTjwRJIfwPTBcLeEwbPr9g8zRrhKll4jvO1wd]benzlim83@y...[/url
Sent: Saturday, November 29, 2003 11:56 PM
To: basicstamps@yahoogroups.com
Subject: Re: [noparse][[/noparse]basicstamps] out of variable (help)
hi jonathan,
As u have bring up abt the 8 program slots, how would i drop the DS1624
code in one slot and your main program in another. Is there any command
for it?
Regards
Ben
Jonathan Peakall <jpeakall@p...> wrote:
Ben,
For example:
Serial_Out VAR BYTE
baud VAR byte
Serial_Out = 0
baud = 17197
Main:
serout serial_out,baud, [noparse][[/noparse]"Hello World"]
goto main
Would send the "Hello World" string to a serial device, like an LCD.
People often write the code like this so they can easily change the pin
that the serial data goes out on, and the baud rate. But, if you want,
you can "hardcode" the variables, like this:
main:
serout 0,17197,[noparse][[/noparse]"Hello World"]
goto main
However, as Bruce just pointed out, CONs don't use variable space (I
didn't realize this) you could write:
Serial_Out CON 0
baud CON 19197
Main:
serout serial_out,baud, [noparse][[/noparse]"Hello World"]
goto main
Of course, this only works if the number can remain the same during the
program, but the same applies to hardcoding.
I don't have time this AM to look at your code in detail, but it does
seems as if there should be plenty of variable space left. Is this the
complete program? If not, send us the complete code. A quick look at the
program shows it won't save a lot of room to hardcode some vars, so thet
idea won't really help, but there are other ways.
Also, you can use a different slot. As you probably know, the BS2s all
have 8 program slots. You can drop the DS1624 code in one slot and your
main program in another. Then, call the slot with the DS1624 from your
main program. There are some good docs on the Parallax site about the
use of slots.
Hope this helps,
Jonathan
www.madlabs.info
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
[noparse][[/noparse]Non-text portions of this message have been removed]
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....