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

How can I avoid sending a repeated start between TWI write and TWI read?

I am communicating with a temperature sensor (MLX90614), which has flag register. However, in order to read this register, I must send a read sequence without issuing the repeated start between the write and read operations. Here is what I want to do in a step-by-step approach:

  1. Send start
  2. Send the slave address ID with the nWrite bit low (8 bits)
  3. Receive an ACK from the slave
  4. Send out the command to read the flags, 0xF0 (8 bits)
  5. Receive an ACK from the slave
  6. Do not send a repeated start. (Normally, there would be a repeated start here).
  7. Send the slave address with the nWrite bit high, indicating a read (8 bits)
  8. Send out 16 bits of clock to read in the MSB and LSB from the slave, placing ACKs appropriately.
  1. Issue a stop.

I think that I need to use GPIOTE with PPI to get this to work, but do not know how to specify the number of toggles that would be needed to describe the event. And upon describing the event, what action should be taken.

Can someone advise?

Thank you,

Noah

Parents
  • You can use the APP_TWI module. There you have the app_twi_perform function that gets a list of the twi tasks to execute. These tasks can be read or write, and they have the option not to issue the stop condition. You can have a list of tasks as follow:

    1. WRITE register address (set no_stop = true - after this write you don't want to issue the stop condition because a READ will follow immediately).

    2. READ (this time no_stop should be set to false.

    When you set no_stop = true for the Write operation instead of issuing the stop condition it will let the following Read issue its start condition. The stop condition has to be present at the end of this Read. What version of the SDK do you have?

    At the end your secvention will look like this:

    START COND | ADDR + Write bit | REG ADDR | START COND | ADDR + Read bit | | STOP COND.

Reply
  • You can use the APP_TWI module. There you have the app_twi_perform function that gets a list of the twi tasks to execute. These tasks can be read or write, and they have the option not to issue the stop condition. You can have a list of tasks as follow:

    1. WRITE register address (set no_stop = true - after this write you don't want to issue the stop condition because a READ will follow immediately).

    2. READ (this time no_stop should be set to false.

    When you set no_stop = true for the Write operation instead of issuing the stop condition it will let the following Read issue its start condition. The stop condition has to be present at the end of this Read. What version of the SDK do you have?

    At the end your secvention will look like this:

    START COND | ADDR + Write bit | REG ADDR | START COND | ADDR + Read bit | | STOP COND.

Children
No Data
Related