photomankc
New Member
Got a PICAXE 20X2 that is doing a great job running 3 sonar sensors for me and getting distance results for them. The PICAXE idea was to be a sub-controller to keep me from burning a core and 6 I/O lines in another processor polling and firing these sensors. The idea is to connect to the I2C bus and have the master read the values from the PICAXE when it needs or wants them.
It now comes to mind that since the I2C read is background to the rest of the program, and the values are all word size numbers, it will be very possible for the I2C read to get partially updated values as it reads through the memory locations and the PICAXE is bust scanning and updating away. I can't think of a reasonable way to either tell the picaxe to hold updates, or tell the master to wait.
Best idea I could come up with is an I2C command that tells the PICAXE to stop scanning, then the master reads the data, then start scanning again. That would slow things down a lot. Is there any way to make the PICAXE stretch the clock till it's all the data is updated? Are "put ADR, word DATA" considered atomic anyway?
It now comes to mind that since the I2C read is background to the rest of the program, and the values are all word size numbers, it will be very possible for the I2C read to get partially updated values as it reads through the memory locations and the PICAXE is bust scanning and updating away. I can't think of a reasonable way to either tell the picaxe to hold updates, or tell the master to wait.
Best idea I could come up with is an I2C command that tells the PICAXE to stop scanning, then the master reads the data, then start scanning again. That would slow things down a lot. Is there any way to make the PICAXE stretch the clock till it's all the data is updated? Are "put ADR, word DATA" considered atomic anyway?