Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Problem with reading I2C
Author | Message | ||||
Frank N. Furter Guru Joined: 28/05/2012 Location: GermanyPosts: 831 |
Did anyone tested the I2CRCV command with only on Byte and an "normal" variable? I have to communicate with a ISL29023 light-sensor and want to read only one byte. When I use the example "I2CRCV &h6f, 1, 1, avar" (or when I use my address with my variable) I get an error: "Error: Invalid variable" ??? ...but it works very well when I use an array and read my data in only one cell!!?? Doesn't work: I2CRCV &H44, 0, 1, test Work: DIM test(1) I2CRCV &H44, 0, 1, test(0) What's going wrong? THANKS! Frank |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3804 |
Maybe it requires an array, no matter what result(s). John |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
It could be because the variable has not been previously used. Try this: test = 0
I2CRCV &H44, 0, 1, test Did this work? Disclaimer: I did not write the I2C stuff. Geoff Geoff Graham - http://geoffg.net |
||||
Frank N. Furter Guru Joined: 28/05/2012 Location: GermanyPosts: 831 |
Hi Geoff, very good Idea! ...and it works!!! I get no Errormessage when I use the variable before and my code works, I can read out my sensor! THANKS! Frank |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
Thanks for the feedback, I will fix it in the next version. Geoff Graham - http://geoffg.net |
||||
Print this page |