Forum Discussion
Hi Jacob
Sorry that I have suggested you to change the addressing mode from 7 to 10bit.
I misunderstood that your addressing is greater than 7 Bit.
For the register address in the device, if it is greater that FF, then you would need to send another extra byte for the register address.
It is normal in this case, because all data send in the i2c bus are byte size.
In your case if you would like to read a register address greater than 0xFF then you would need to send a total of 3 bytes to initiate the read.
e.g.
<device address byte> <register address byte 1> <register address byte 2> ... <remaining bytes>
Could you share the datasheet of the device that you are trying to read from?
Regards
Jingyang, Teh
- Jacob113 years ago
Occasional Contributor
Hello Jingyang,
I understand this point. However, in the driver provided by Intel there is already functionality for this that seems to not function. See the code snippet i posted above:
if (reg > 0xff) {txbuf[0] = reg;txbuf[1] = reg >> 8;txsize = 2;} else {txbuf[0] = reg;txsize = 1;}Lets say the register is 0x0318.txbuf is an array of alt_u8 integers. So we have:alt_u8 data = 0xDD;alt_u8 txbuff[2];if (reg > 0xff) ----YESso,txbuf[0] = 0x18 (this is 0x318 converted to alt_u8.txbuff[1] = 0x03 (0x0318 >>= 0x03; txsize = 2;So now I send the txbuf with the register as the first 2 bytes.The intel driver takes care of the rest with this function calls:alt_avalon_i2c_master_transmit(i2c_dev, txbuff, txsize, ALT_AVALON_I2C_NO_RESTART, ALT_AVALON_I2C_NO_STOP);with this function call 0x03 then 0x18 are sent over the i2c bus sequentially....so this point should already exist in the driver. But it isn't working. I can try something manually, but it would be nice to just use the intel functions since we are already using them for everything.Thanks,Jacob