TWIM: EasyDMA transfers - STOP Task before STARTED Event

What happens if I trigger the STOP task to an I2C transaction that hasn't had a STARTED event yet? Will the STOPPED event immediately happen, or will the peripheral wait for a transaction to actually happen?

Background: I would like to set up automatic TWI master reads (TXRX) triggered by an external GPIO toggle along with using the EasyDMA list feature (implying NRFX_TWIM_FLAG_HOLD_XFER, NRFX_TWIM_FLAG_REPEATED_XFER, & NRFX_TWIM_FLAG_RX_POSTINC). These reads would proceed to fill a large buffer.  Asynchronous to this, I would like to periodically read out any collected data before having to wait until the next transaction to occur.

Sorry for the crude drawing, but what I'm looking to do the following, but I will not know I need the data prior to actually immediately requesting it.

Parents
  • Hello,

    I can understand what you want to do here, but I would suggest that you evaluate run-time when the next periodic reading of twi is relative to when you want to perform an manual reading, e.g. if you see that the time to next periodic reading is for instance less than the time to perform an twi transaction, then consider waiting or disable the ppi channel that may trigger the the periodic twi channel. If you see that you want to perform an manual twi transcation shortly after the periodic twi transfer is still ongoing, then you should wait with the manual twi transfer. 

    Doing it like above should avoid that you need to trigger stop task, instead you make sure to perform manual twi transcation at safe time, and if you don't want to perform a periodic twi transaction you instead disable the ppi channel in those situations. Reasons for doing it like this I deem it safer than all the possible corner cases of performing stop shortly after executing a start task (this might also be something the sensor is not happy about).

    Kenneth

  • Sorry, point of clarification, there would not be any manual twi transactions.  By "Get data here" I mean that the application would simply consume the data already filled in the existing buffer. 

    In short, I'm trying to figure out a way to automatically read in twi data on a 'data ready' gpio pin while allowing the application access to all the received data without having to wait until another transaction to occur. 

    If there are too many corner cases with the STOP before STARTED approach, the alternative is that I could 'peek' inside the RX DMA buffer while the DMA engine is still running.  Are there any pitfalls with this approach?

  • That simplifies things a bit, there is no problem to read data directly from RAM between transcations no, the only exception may be if you read at the same time as a transaction is ongoing, then you may possible get only partial data of a on-going transfer (but reading again a bit later should solve even that).

    Kenneth

Reply Children
Related