Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 10:33 30 Apr 2024 Privacy Policy
Jump to

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: Germany
Posts: 813
Posted: 02:19am 28 Oct 2013
Copy link to clipboard 
Print this post

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!

FrankEdited by Frank N. Furter 2013-10-29
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3659
Posted: 02:29am 28 Oct 2013
Copy link to clipboard 
Print this post

Maybe it requires an array, no matter what result(s).

John
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 02:46am 28 Oct 2013
Copy link to clipboard 
Print this post

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: Germany
Posts: 813
Posted: 08:34pm 28 Oct 2013
Copy link to clipboard 
Print this post

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: Australia
Posts: 3165
Posted: 04:55am 29 Oct 2013
Copy link to clipboard 
Print this post

Thanks for the feedback, I will fix it in the next version.
Geoff Graham - http://geoffg.net
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024