I2c 16bit register access

153 views
Skip to first unread message

D Srinivasa Reddy

unread,
Oct 22, 2020, 3:18:01 AM10/22/20
to inside...@googlegroups.com
Hi Anil,
I have one i2c slave whose registers are to be accessed by 16bit register addresses. data at registers is 8bit. How to access 16bit registers of i2c device. if I write as below it is not working. 

  buf[0]=(0x00FF&regbuf[i].address);  /* first 8bit LSB address [7:0] */
  buf[1]=((0xFF00&regbuf[i].address)>>8);  /*second 8bit, MSB of address [15:8] */
  buf[2]=regbuf[i].value;   /* 8 bit data to write to 16bit address */
 
  if (write(file, buf, 3) != 3) { 
   }

Thanks and Regards
srinivasa

Abhishek Kumar Trivedi

unread,
Oct 25, 2020, 3:41:08 AM10/25/20
to inside...@googlegroups.com
Hello

You didn't send slave address, before register address you need to send slave adress.

Regards
Abhishek kumar Trivedi  

--
You received this message because you are subscribed to the Google Groups "SysPlay's Inside Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to inside_linux...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/inside_linux/CAOKcRMvq0phi6r%2BqrFsP_fyav%3D9a3hjnjDAG8azMShtK0U%3DVbA%40mail.gmail.com.


--
Regards
Abhishek Kumar Trivedi

D Srinivasa Reddy

unread,
Oct 25, 2020, 7:24:02 AM10/25/20
to inside...@googlegroups.com
Hi Abhishek, ofcourse without slave address i2c controller won't detect the device, can't probe device ready itself. The question is if the i2c device has >256 registers address space, how those registers can be accessed.Anyway I got solution.

Anil Kumar Pugalia

unread,
Oct 26, 2020, 12:55:19 PM10/26/20
to inside...@googlegroups.com

Typically, 16-bit addressing is the solution. But more than that the device data sheet should tell us as what exactly to send to the device. Anyways, please share the solution you got.

Thanks & Regards
Anil
Passion: http://sysplay.in (Playing with Systems)
D Srinivasa Reddy wrote on 25/10/20 4:53 pm:

D Srinivasa Reddy

unread,
Nov 6, 2020, 9:13:45 AM11/6/20
to inside...@googlegroups.com
Anil sir, forgot to reply. as you have mentioned device data sheet is only the way, somewhere bridge registers are mentioned through which master can access 64KB address space of the device.

Thanks and regards
srinivasa

Reply all
Reply to author
Forward
0 new messages