Calculating i2C Slave address | 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 3 characters - maximum search word length is 84 characters
sp_Feed Topic RSS sp_TopicIcon
Calculating i2C Slave address
June 20, 2018
10:11 am
Avatar
Chrisreed
Member
Members
Forum Posts: 19
Member Since:
March 23, 2015
sp_UserOfflineSmall Offline

For a MAX7318 (i2c 16-bit I/O Port Expander) with address lines A0, A1, A2 all grounded the 7-bit Slave address in the datasheet is specified as:

A6 A5 A4 A3 A2 A1 A0

0   1   0   0  0   0   0   or 0x40 (hex).  It seems the Hex value is derived by adding a "0" to the LSB of the address (bit shift left)

However to get the i2c VI's to work I used the Slave address of 0x20  ie. I had to add a "0" to the MSB of the Slave address ie. A7 (bit shift right).

I now seem to have a similar problem with the AMC6821 i2C Fan Controller where the two address lines (A0/A1) are both grounded and so the datasheet has a slave address of:

A6 A5 A4 A3 A2 A1 A0

0   0   1   1  0   0   0   or 0x30 (hex) if adding a "0" to LSB,  but should it be 0x18 (ie. 0001 1000) for the Slave address (ie. add "0" to MSB)?

Chris

June 20, 2018
10:18 am
Avatar
Chrisreed
Member
Members
Forum Posts: 19
Member Since:
March 23, 2015
sp_UserOfflineSmall Offline

Oops - so my actual question was....

when using the i2c VI's should I add a "0" to the MSB or LSB of the slave address specified in the datasheet?

Chris

June 26, 2018
10:51 pm
Avatar
Steffan
Admin
Forum Posts: 408
Member Since:
March 12, 2015
sp_UserOfflineSmall Offline

Address is handled exactly as documented in the Arduino Wire library here:

Note

There are both 7- and 8-bit versions of I2C addresses. 7 bits identify the device, and the eighth bit determines if it's being written to or read from. The Wire library uses 7 bit addresses throughout. If you have a datasheet or sample code that uses 8 bit address, you'll want to drop the low bit (i.e. shift the value one bit to the right), yielding an address between 0 and 127. However the addresses from 0 to 7 are not used because are reserved so the first address that can be used is 8. 

July 3, 2018
10:36 am
Avatar
Chrisreed
Member
Members
Forum Posts: 19
Member Since:
March 23, 2015
sp_UserOfflineSmall Offline

Thanks Steffan I got it working eventually.  I was using the correct Slave address all along, but the chip was faulty, which is why I wasn't getting any replies 🙁

Chris

Forum Timezone: UTC 0
Most Users Ever Online: 100
Currently Online:
12
Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
miche91: 33
scottj: 28
scadao: 23
Member Stats:
Guest Posters: 5
Members: 202
Moderators: 0
Admins: 3
Forum Stats:
Groups: 1
Forums: 2
Topics: 266
Posts: 1222
Newest Members:
pujacontrol
Administrators: geadmin: 22, filipealtoe: 96, Steffan: 356