This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

TWI interface slave address

Hi,

I need to interface a LED driver (PCA9632) using TWI. In the TWI APIs I can't see any way to pass the slave address to the TWI instance. Speaking about the nrf_drv_twi_init function, there is no field in the parameters structs that accepts a slave address. What's the right way to use the TWI interface ?

Thanks, Paolo.

Parents
  • nrf_drv_twi_tx(), nrf_drv_twi_rx() all take address parameters. The TWI interface itself isn't tied to any given address, it's able to address different slaves on each send/receive.

    Please see the documentation and search for 'address'

  • Nope - if you want to just write something to the slave you use its address (which won't be 0xC4 because that's 8-bit, probably more likely 0x62) with the data you want written in whatever format the slave expects it. The data sheet for the slave will tell you what sequence of bytes address the internal register, that's part of the data not the address. perhaps the first byte of data will be 0x02 denoting a write to that register and the rest of the data will be data, perhaps the first byte will be a byte indicating a write to a register, the second byte will be 0x02 and the data will follow. All depends on your slave.

    None of that however has anything to do with the slave address which is always prepended to sequence of data sent out on the wire.

Reply
  • Nope - if you want to just write something to the slave you use its address (which won't be 0xC4 because that's 8-bit, probably more likely 0x62) with the data you want written in whatever format the slave expects it. The data sheet for the slave will tell you what sequence of bytes address the internal register, that's part of the data not the address. perhaps the first byte of data will be 0x02 denoting a write to that register and the rest of the data will be data, perhaps the first byte will be a byte indicating a write to a register, the second byte will be 0x02 and the data will follow. All depends on your slave.

    None of that however has anything to do with the slave address which is always prepended to sequence of data sent out on the wire.

Children
No Data
Related