Need some help figuring out what is happening here
DDS
Posts: 16
I have a program that reads some I2C data from a couple of devices. The program (attached) works as follows:
(All this is done in cog 0)
I initialize the I2C chips and get the other objects running.
I call the I2C sampling code and display the data on the serial port (see the top two lines below for what it is supposed to look like).
I then start a new cog with the same sampling routine but it reads bad data IF the "repeat" on line "999" is present but works fine if the "repeat" on line "999" is removed.
My question is: what is happening to all the code in cog 0 (serial driver, I2C driver, etc.) when I include the repeat that makes it work ok when the repeat is missing and it runs out of code to execute?
I realize that the cogs are running the SPIN interpreter and the program is being pulled from the common ram.
Screen dump: Top two lines are correct, lower 3 lines are bad data generated from the same routine but when running in a separate cog.
lChannel= 1 lHex= 0 IMuxC= 00001 EMuxA= 00000 EMuxC= 00001 Addr= 73 Type= 0 Value= 0000FBFC
lChannel= 2 lHex= 0 IMuxC= 00002 EMuxA= 00000 EMuxC= 00001 Addr= 79 Type= 2 Value= 00001840
lChannel= 1 lHex= 0 IMuxC= 00001 EMuxA= 00000 EMuxC= 00001 Addr= 73 Type= 0 Value= 0000FFFF
lChannel= 2 lHex= 0 IMuxC= 00002 EMuxA= 00000 EMuxC= 00001 Addr= 79 Type= 2 Value= 0000FFFF
lChannel= 1 lHex= 0 IMuxC= 00001 EMuxA= 00000 EMuxC= 00001 Addr= 73 Type= 0 Value= 0000FFFF
(All this is done in cog 0)
I initialize the I2C chips and get the other objects running.
I call the I2C sampling code and display the data on the serial port (see the top two lines below for what it is supposed to look like).
I then start a new cog with the same sampling routine but it reads bad data IF the "repeat" on line "999" is present but works fine if the "repeat" on line "999" is removed.
My question is: what is happening to all the code in cog 0 (serial driver, I2C driver, etc.) when I include the repeat that makes it work ok when the repeat is missing and it runs out of code to execute?
I realize that the cogs are running the SPIN interpreter and the program is being pulled from the common ram.
Screen dump: Top two lines are correct, lower 3 lines are bad data generated from the same routine but when running in a separate cog.
lChannel= 1 lHex= 0 IMuxC= 00001 EMuxA= 00000 EMuxC= 00001 Addr= 73 Type= 0 Value= 0000FBFC
lChannel= 2 lHex= 0 IMuxC= 00002 EMuxA= 00000 EMuxC= 00001 Addr= 79 Type= 2 Value= 00001840
lChannel= 1 lHex= 0 IMuxC= 00001 EMuxA= 00000 EMuxC= 00001 Addr= 73 Type= 0 Value= 0000FFFF
lChannel= 2 lHex= 0 IMuxC= 00002 EMuxA= 00000 EMuxC= 00001 Addr= 79 Type= 2 Value= 0000FFFF
lChannel= 1 lHex= 0 IMuxC= 00001 EMuxA= 00000 EMuxC= 00001 Addr= 73 Type= 0 Value= 0000FFFF
Comments
It is the stock driver from the obex with some minor changes (I don't know what all I changed at this point in time).
Thanks for the help,
Don
The weird thing is that this (stripped down) program works fine if I remove the last "REPEAT" command and let the spin interpreter run out of code but if I include the REPEAT, it fails to talk to the I2C chips.
I stripped out the clock/calender driver but it did the same thing.
Exactly what happens to all the program when it runs out?
Who handles the serial driver, etc. Does it in fact shut the cog down when it runs out of code.
I can see no conflict when the program is started in a second cog as I effectively terminate the first cog with either no code or a infinite repeat
Any ideas?
PS : * or better : it makes me wonder ;o)
Post Edited (MagIO2) : 6/23/2010 7:03:05 PM GMT
I use the Mike Green's basic I2C, works like a charm. Johnny Mac's I2C code works great too.