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

PPI on TWI instance 1 not working

I have adapted the "nrf52-mpu-easydma-using-timers-and-drivers" project from Github that I saw referenced in another post and have successfully modified it to work with my A/D converter on TWI instance 0.  However, I have implemented a virtual "ditto" of this design on TWI instance 1 and the TWI transfers never happen.  I can tell from the debug terminal that all 4 of the PPI channels appear to be set up properly (channels 0 - 3, 2 channels for each TWI instance) and have tested to confirm that the timer instance that should generate the TWI transfers is indeed triggering at the desired interval (tested by temporarily enabling the timer handler and toggling a GPIO pin).  I can share the code on a private ticket if needed, but I first want to confirm that this should be capable of working on two TWI instances.  Since they aren't on the same bus, I would have thought that this should be ok.  I appreciate any feedback/assistance.

UpdateI forgot to mention I'm using SDK 15.2 (was being used by one of our partners, so we're staying aligned) and SES 3.40, just in case that is relevant.  Also, I know the TWI instance 1 is set up properly because the init routine performs a proper tx/rx to configure the I2C accelerometer on that bus.

  • It's not an elegant solution, but I'll describe it the best I can.  I didn't actually change the slave address using PPI, as I understand it.  I am using the timer handler (not the one for the counter, but for the other timer in the PPI implementation - it's unused in the sample project) to process two compare events.  On one event, the proper DAC data value for this pass through is stored in a variable and a task scheduler function call is made.  This particular task scheduler function uses nrf_twim_address_set()/nrf_twim_tx_buffer_set() to set the DAC slave address and update the TX buffer with the write data.  I don't make the actual xfer here - just wait for the existing PPI functions to perform the TXRX for the DAC.  On the next pass through, the other compare event includes a call to the task scheduler that uses the same two nrf functions to restore the slave address and TX data back to the appropriate values for the ADC.  So, I had to increase the timer to double the frequency since it now has to perform both the DAC and ADC xfers while maintaining my target sampling rate.  I have simple logic to make sure only one of the compare events (which are very similar in # of ticks) results in updates to the slave address / tx data for each pass through.  I realize the timer handler can have up to 250us of delay since I'm also using a SoftDevice, so I had to take that into account to ensure that the address updates don't happen too late (timer is at over 1ms, so I have plenty of time).  I'm happy to answer any other questions, as I've received tremendous support through the dev zone and will clarify/contribute if I can.

  • Thanks for the explanation. If you are doing the address/buffer update in software/interrupt handler I can understand that you made it work, I just thought that you had a solution to do this with PPI only, which I could not understand how would be possible.

Related