Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor III
851 Views

mraa_i2c_address above 0x7F returns MRAA_ERROR_INVALID_HANDLE

Jump to solution

Here is my code

int rtv;int rav;

rtv = mraa_init();

if (rtv != MRAA_SUCCESS && rtv != MRAA_ERROR_PLATFORM_ALREADY_INITIALISED)

{

printf( "ER MRAA Init Failed,Return Value is %d\n",rtv);

return -1;

}

i2c = mraa_i2c_init(0);

rav = mraa_i2c_address(i2c, ADDR);printf("** return value is %d\n",rav);

With no i2c devices connected all values of ADDR 0x7F and below return 0 and all values of ADDR above 0x80 return 5,

My problem is that I have two i2c devices on the buss. One is address 0x5C and the other 0X9A. The device with address 0x5C is working fine but I just get error returns for the one with address 0x9A.

I tried it with chips installed and without chips installed. It makes no difference. I get error 5 with high order addresss and 0 with addresses below 0x7F and below.

My choices of addresses are 0x9n and 0xAn. There are lots of choices of n but only 9 or A for the first nibble.

I also tried defining a variable of type uint8_t and using that instead of the 0x9A but no difference

 

.

Accepted Solutions
Highlighted
New Contributor III
13 Views

Well, that was an easy answer. One device has an address in its data sheet of 5C and the other has an address in the data sheet of 9A. The address of the first device is in fact 5C when using mmra. The second device uses 0x4D when using mmra, its published address shifted right one bit. Code works now.

Hope this helps someone else.

Allen

View solution in original post

0 Kudos
1 Reply
Highlighted
New Contributor III
14 Views

Well, that was an easy answer. One device has an address in its data sheet of 5C and the other has an address in the data sheet of 9A. The address of the first device is in fact 5C when using mmra. The second device uses 0x4D when using mmra, its published address shifted right one bit. Code works now.

Hope this helps someone else.

Allen

View solution in original post

0 Kudos