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
I2C stops program
Moderator: Benj
-
- Posts: 1314
- Joined: Sun Jan 15, 2012 3:15 pm
- Has thanked: 474 times
- Been thanked: 458 times
- Contact:
Re: I2C stops program
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
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
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php
-
- Posts: 45
- Joined: Mon Dec 22, 2008 11:22 pm
- Location: Prospect, NS, Canada
- Has thanked: 7 times
- Been thanked: 2 times
- Contact:
Re: I2C stops program
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
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
- Attachments
-
- Get_light.fcm
- (4.28 KiB) Downloaded 278 times
-
- Posts: 1314
- Joined: Sun Jan 15, 2012 3:15 pm
- Has thanked: 474 times
- Been thanked: 458 times
- Contact:
Re: I2C stops program
Hi
Can you attach your complete flowchart
Regards
Dazz
Can you attach your complete flowchart
Regards
Dazz
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php
-
- Posts: 170
- Joined: Sat Dec 10, 2011 7:21 pm
- Location: Canada
- Has thanked: 20 times
- Been thanked: 52 times
- Contact:
Re: I2C stops program
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?
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?
-
- Posts: 45
- Joined: Mon Dec 22, 2008 11:22 pm
- Location: Prospect, NS, Canada
- Has thanked: 7 times
- Been thanked: 2 times
- Contact:
Re: I2C stops program
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
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