I2CIN Help
The I2CIN command doesn't arbitrarily clear variables. Without
seeing your code, I'm guessing you may be reading in more bytes of
data than you have set aside for their receipt, thereby storing the
incoming data into other variables' locations. If you'll post your
code, someone will probably see the problem.
Regards,
Steve
On 20 Sep 02 at 18:53, pjk_usa2002 wrote:
> Can someone tell me why when I use the "I2CIN" command it resets all
> of my variables to "0"...
seeing your code, I'm guessing you may be reading in more bytes of
data than you have set aside for their receipt, thereby storing the
incoming data into other variables' locations. If you'll post your
code, someone will probably see the problem.
Regards,
Steve
On 20 Sep 02 at 18:53, pjk_usa2002 wrote:
> Can someone tell me why when I use the "I2CIN" command it resets all
> of my variables to "0"...
Comments
of my variables to "0". The only work around I have found is to use
the "PUT" command for all of my variables to scratch pad ram before
the "I2CIN" command executes and a "GET" command to retreive after...
Thank you in advance
lot of work with I2CIN and have never had any trouble with it. What you're
experiencing is not the norm -- I'm wondering if you have a bus short that is
causing the Stamp to reset.
-- Jon Williams
-- Parallax
In a message dated 9/20/02 1:55:38 PM Central Daylight Time,
pkocmoud@h... writes:
> Can someone tell me why when I use the "I2CIN" command it resets all
> of my variables to "0". The only work around I have found is to use
> the "PUT" command for all of my variables to scratch pad ram before
> the "I2CIN" command executes and a "GET" command to retreive after...
>
>
[noparse][[/noparse]Non-text portions of this message have been removed]
to CHAN1...After the 1st (See in Code Below) I2CIN command, the SerInPort
and SerSpeed varibles goto 0 and the next (See in Code Below)I2CIN command
gets stupid due to the lack on Address and Command Variables. I can
subastute the variables for constants and it works fine! This is my
problem...
'{$STAMP BS2p}
Value VAR WORD
ValueLow VAR BYTE
ValueHigh VAR BYTE
Channel VAR BYTE
ADAddress VAR BYTE
SerInPort VAR BYTE
SerOutPort VAR BYTE
SerSpeed VAR BYTE
Command1 CON %10001100
Command2 CON %11001100
Command3 CON %10011100
Command4 CON %11011100
Command5 CON %10101100
Command6 CON %11101100
Command7 CON %10111100
Command8 CON %11111100
ADAddress = %10010001
SerSpeed = 240
SerInPort = 16
SerOutPort = 16
INITIALIZE:
Debug "Hello"
MAIN:
DEBUG "WAITING", " " , BIN SERINPORT, " " , BIN sERsPEED
SERIN SerInPort,SerSpeed,[noparse][[/noparse]DEC Channel]
Branch Channel, [noparse][[/noparse]ZERO,CHAN1,CHAN2,CHAN3,CHAN4,CHAN5,CHAN1,CHAN6,CHAN7,CHAN8]
Goto ERROR
CHAN1:
DEBUG "Entered 1"
SEROUT SerOutPort,SerSpeed, [noparse][[/noparse]65]
I2CIN 8,ADADDRESS, COMMAND8,[noparse][[/noparse]STR VALUE\16]
<
1st Execution
DEBUG cls, BIN COMMAND1, " ",BIN ADADDRESS, " " , DEC VALUE, cr
I2CIN 8,ADADDRESS, COMMAND2,[noparse][[/noparse]VALUE]
<
2st Execution
DEBUG BIN COMMAND2, " ",BIN ADADDRESS, " " , DEC VALUE, cr
I2CIN 8,ADADDRESS, COMMAND3,[noparse][[/noparse]VALUE]
DEBUG BIN COMMAND3, " ",BIN ADADDRESS, " " , DEC VALUE, cr
I2CIN 8,ADADDRESS, COMMAND4,[noparse][[/noparse]VALUE]
DEBUG BIN COMMAND4, " ",BIN ADADDRESS, " " , DEC VALUE, cr
I2CIN 8,ADADDRESS, COMMAND5,[noparse][[/noparse]VALUE]
DEBUG BIN COMMAND5, " ",BIN ADADDRESS, " " , DEC VALUE, cr
I2CIN 8,ADADDRESS, COMMAND6,[noparse][[/noparse]VALUE]
DEBUG BIN COMMAND6, " ",BIN ADADDRESS, " " , DEC VALUE, cr
I2CIN 8,ADADDRESS, COMMAND7,[noparse][[/noparse]VALUE]
DEBUG BIN COMMAND7, " ",BIN ADADDRESS, " " , DEC VALUE, cr
I2CIN 8,ADADDRESS, COMMAND8,[noparse][[/noparse]VALUE]
DEBUG BIN COMMAND8, " ",BIN ADADDRESS, " " , DEC VALUE
GOTO MAIN
<<<<EXCERPT>>>>
Original Message
From: S Parkis [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=tfdVLCuCzb8CQs-leOHD0ZbPGyb60jQqrAexs0BMWcLXL7jbi_o3upO6XPTcaLP3hkw4z-yNOahkm2X4]parkiss@e...[/url
Sent: Friday, September 20, 2002 12:03 AM
To: basicstamps@yahoogroups.com
Subject: Re: [noparse][[/noparse]basicstamps] I2CIN Help
The I2CIN command doesn't arbitrarily clear variables. Without
seeing your code, I'm guessing you may be reading in more bytes of
data than you have set aside for their receipt, thereby storing the
incoming data into other variables' locations. If you'll post your
code, someone will probably see the problem.
Regards,
Steve
On 20 Sep 02 at 18:53, pjk_usa2002 wrote:
> Can someone tell me why when I use the "I2CIN" command it resets all
> of my variables to "0"...
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/
I've been working with I2CIN all day and haven't experienced what you're
seeing.
As someone else mentioned, it might be some sort of a brownout
condition. Do you have any sort of audible or visual indicator of
program start (like the piezo beep example used in the Boe Bot?) might
be a good idea, at least during the development phase.
On Fri, 2002-09-20 at 14:53, pjk_usa2002 wrote:
> Can someone tell me why when I use the "I2CIN" command it resets all
> of my variables to "0". The only work around I have found is to use
> the "PUT" command for all of my variables to scratch pad ram before
> the "I2CIN" command executes and a "GET" command to retreive after...
>
>This is an excerpt of my code. Assuming you press 1 and the program branches
>to CHAN1...After the 1st (See in Code Below) I2CIN command, the SerInPort
>and SerSpeed varibles goto 0 and the next (See in Code Below)I2CIN command
>gets stupid due to the lack on Address and Command Variables. I can
>subastute the variables for constants and it works fine! This is my
>problem...
Phillip -
Try starting with something other than Port 16 and see if anything changes.
Regards,
Bruce Bates
bytes of data and put it in variable called Value. The Stamp will happily do
this. What's happening though, is the compiler is assigning Value to RAM
locations zero and one since it's a Word and Words are assigend first. So,
your I2CIN line is overwriting your other variables -- you [noparse][[/noparse]inadvertently]
told it to.
Change your definition to this:
value VAR Byte(16)
to allocate 16 bytes of RAM space for your data.
If your intention was to read 16 bits, you don't need the \16. Change your
I2CIN line to this:
I2CIN 8,ADADDRESS, COMMAND8,[noparse][[/noparse]value.LowByte, value.HighByte]
This works because I2C devices are byte-oriented.
I hope this helps.
-- Jon Williams
-- Parallax
In a message dated 9/20/02 3:48:47 PM Central Daylight Time,
pkocmoud@h... writes:
> This is an excerpt of my code. Assuming you press 1 and the program branches
> to CHAN1...After the 1st (See in Code Below) I2CIN command, the SerInPort
> and SerSpeed varibles goto 0 and the next (See in Code Below)I2CIN command
> gets stupid due to the lack on Address and Command Variables. I can
> subastute the variables for constants and it works fine! This is my
>
[noparse][[/noparse]Non-text portions of this message have been removed]
Phil
Original Message
From: jonwms@a... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=AvN3VoMtMPm0G_iB6iiW5Zem_CgTn_rAXq8N6nScCGRu2TrIYfhz6Izih3HdtXbyZha3oL2U]jonwms@a...[/url
Sent: Friday, September 20, 2002 5:51 PM
To: basicstamps@yahoogroups.com
Subject: Re: [noparse][[/noparse]basicstamps] I2CIN Help
I believe I found your problem. Your I2CIN line tells the Stamp to get 16
bytes of data and put it in variable called Value. The Stamp will happily
do
this. What's happening though, is the compiler is assigning Value to RAM
locations zero and one since it's a Word and Words are assigend first. So,
your I2CIN line is overwriting your other variables -- you [noparse][[/noparse]inadvertently]
told it to.
Change your definition to this:
value VAR Byte(16)
to allocate 16 bytes of RAM space for your data.
If your intention was to read 16 bits, you don't need the \16. Change your
I2CIN line to this:
I2CIN 8,ADADDRESS, COMMAND8,[noparse][[/noparse]value.LowByte, value.HighByte]
This works because I2C devices are byte-oriented.
I hope this helps.
-- Jon Williams
-- Parallax
In a message dated 9/20/02 3:48:47 PM Central Daylight Time,
pkocmoud@h... writes:
> This is an excerpt of my code. Assuming you press 1 and the program
branches
> to CHAN1...After the 1st (See in Code Below) I2CIN command, the SerInPort
> and SerSpeed varibles goto 0 and the next (See in Code Below)I2CIN command
> gets stupid due to the lack on Address and Command Variables. I can
> subastute the variables for constants and it works fine! This is my
>
[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/