I2C stops program

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
henker
Posts: 45
Joined: Mon Dec 22, 2008 11:22 pm
Location: Prospect, NS, Canada
Has thanked: 7 times
Been thanked: 2 times
Contact:

I2C stops program

Post 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
Last edited by henker on Fri Nov 22, 2013 3:50 am, edited 1 time in total.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: I2C stops program

Post 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
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

henker
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

Post 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
Attachments
Get_light.fcm
(4.28 KiB) Downloaded 278 times

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: I2C stops program

Post by dazz »

Hi
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

GTF
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

Post 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?

henker
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

Post 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

Post Reply