This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to configure TWI/I2C for high Write Bit

Hello,

I am checking to see if it is possible to use app_twi_perform() to transmit TWI transactions that have a High Write bit. I have changed the polarity of APP_TWI_WRITE_OP, APP_TWI_READ_OP and APP_TWI_IS_READ_OP. I still see, on a scope, that the the 8th bit is a low when it is meant to be high for write.

Appreciate any help. I did review open issues to avoid duplication; but, apologies if this was answered before.

Thanks, Prasad

  • Hi.

    I'm looking into this and trying to find a definitive answer and explanation. I tried your method of swapping the LSB in APP_TWI_WRITE_OP and APP_TWI_READ_OP and I think I see the same behaviour as you. However, I suspect that we are only fooling the drivers and not the hardware. As you have seen APP_TWI_WRITE_OP and APP_TWI_READ_OP simply left shifts the seven bit long TWI slave address and appends a READ or WRITE bit. However, the resulting byte is not the exact byte that is clocked out on the TWI bus. Later in the transfer process the TWI library separates the address and R/W bit again. It then checks the LSB and starts either a TX or an RX. The address bits go into the TWI->ADDRESS register (note that it is 7-bit long) and the TWI driver fires either the STARTTX OR STARTRX task. Simply put, by swapping R/W bits in APP_TWI_WRITE_OP and APP_TWI_READ_OP you start a read when trying to start a write and vice versa. Furthermore, by initiating a read transfer you cannot expect the nRF52 TWI hardware to continue to write bytes to the bus. I have asked the designers though, to see if it is at all possible to manipulate the hardware to do what you want, but I am still waiting for an answer.

    May I ask what device you are using that requires swapping read and write bit like this? Sounds like a very odd way to do things.

  • I am using the SI7054 (Silicon Labs temperature sensor). The datasheet specifies (in Table 10) that the WRITE bit is 1. It could be errata because the DS also specifies "the R/W bit is set high for a read command and low for a write command" in Section 5. As I was having a difficulty communicating with this sensor over TWI in an event handler, I wanted to check if I had the R/W bit mixed up.

  • That has got to be a typo in the table. I'm using the same sensor family and it works with the R/W bit set per the standard.

Related