I2C_How to write to a specific register | Arduino Compatible Compiler for LabVIEW Discussions | Forum

Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 4 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
I2C_How to write to a specific register
May 27, 2015
12:22 am
Avatar
sotovasquezandres@gmail.com
Member
Forum Posts: 8
Member Since:
May 27, 2015
sp_UserOfflineSmall Offline

Hi, I want to know if somebody have write to a specific register using I2C VI, for example I am trying to write a value (1) to register 0x3C and address 1E to a compass I2C (HMC5883L) but when I tried to read the register (0x3D) it does not give me any data, could someone help me??? thanks.I2C-Code.pngImage Enlargercorrect-data-with-bus-pirate.jpgImage EnlargerDara-with-compiler-I2C-write-its-3C-and-read-3D-in-this-example-it-is-oposite-for-a-test.jpgImage Enlarger

May 27, 2015
12:52 am
Avatar
Steffan
Admin
Forum Posts: 305
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Some issues I see with your VI off hand.

1) I think you want Master mode don't you?

2) What is the Slave's address?  You have set 0x3C as the Slave address but you said you wanted to write to register 0x3C.  The slave address should be the same for all I2C transactions (you have it set to 0x3C and 0x3D in different places).  Looks like the address should be 0x1E according to this.  I think you are confusing it with the R/W bit, which is technically not part of the address:

https://www.sparkfun.com/tutorials/301

3) Im not sure what the constraints of the hardware are that you are interfacing to, but you should probably have some delay in your while loop otherwise its going to be sending data pretty frequently.

Also check out the DS1307 Real Time Clock example.  That does something very similar.  It writes to 7 registers to set the real time clock and reads from the same registers in a loop using "I2C Request From.vi" and "I2C Read All Bytes.vi".

October 8, 2015
2:19 pm
Avatar
sotovasquezandres@gmail.com
Member
Forum Posts: 8
Member Since:
May 27, 2015
sp_UserOfflineSmall Offline

Thanks Steffan you were right above the R/W bit that was the problema, thanks.

Forum Timezone: UTC 0

Most Users Ever Online: 33

Currently Online:
2 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

John: 18

RTSLVU: 15

Dan6077: 11

Member Stats:

Guest Posters: 0

Members: 80

Moderators: 0

Admins: 3

Forum Stats:

Groups: 1

Forums: 2

Topics: 58

Posts: 289

Newest Members: Travlissah, viktorIcera, HowardClouG, Dianecet, Produktnaodchudzaniex

Administrators: geadmin: 5, filipealtoe: 35, Steffan: 89