Page 1 of 1

I2C stops program

Posted: Fri Nov 22, 2013 2:40 am
by henker
I have never used I2C before, but I just purchased a sensor using the I2C protocol.
According to the Datasheet I need to send the following I2C data:
- Start
- 0x23 -> this is the Slave address
- 0
- 0x10 -> Slave will start measuring
- stop
wait 100 msec
- Start
- 0x23
- 1
+Read High Byte
+Read Low Byte
- stop

SOLVED: (The problem I have that the stop byte is causing the program to stop. As soon as I disable this icon, no problem.)
Also, I'm trying to figure out when to use the MI2C_Transmission_Byte or when to use the MI2C_Send_Byte_Transaction.

Any help will be appreciated
henk

Re: I2C stops program

Posted: Fri Nov 22, 2013 2:48 am
by dazz
Hi
Can you please attach your flowchart and attach the datasheet of the device you are using as it will help to see whats gone wrong

Regards
Dazz

Re: I2C stops program

Posted: Fri Nov 22, 2013 3:07 am
by henker
Dazz,

I have attached the Macro I have created for this. I just noticed that it is not only the stop byte that stops the program.
Again, I have very little to no I2C experience...

http://www.dfrobot.com/image/data/SEN0097/BH1750FVI.pdf

Page 17 on the pdf shows the sequence of the measurement...

Thanks for the help
Henk

Re: I2C stops program

Posted: Fri Nov 22, 2013 9:02 am
by dazz
Hi
Can you attach your complete flowchart

Regards
Dazz

Re: I2C stops program

Posted: Fri Nov 22, 2013 10:46 pm
by GTF
Hi,

The write/read bit should be included with the address byte so that the address will be either 0x46 or 0x47 in high res mode, according to page 7 of the datasheet.

It also appears that the delay needs to be at least 180ms in high res mode if I am reading it correctly.

Grant

edit: also, has the I2C been initialized in your main code, prior to any loops?

Re: I2C stops program

Posted: Sat Nov 23, 2013 3:47 am
by henker
Thanks Grant.
Yes, I issue an "I2C INIT" at the start of my main program.
I will try the 0x46 / 0x47. I didn't realize you have to add that bit to the byte you clock out.

Thanks
henk