Do you have any sample code that shows how to retrieve data via i2c from 2 different device addresses using PPI?
Do you have any sample code that shows how to retrieve data via i2c from 2 different device addresses using PPI?
Hi,
This will only be possible to achieve if you have identical read and write buffer sizes for both devices. You will need to use the EasyDMA array list feature, and fill the array with alternating read and write commands for the two devices. You can then write the TASKS_START register to start a transfer to one device. When you trigger TASKS_START again, the RXD and TXD buffers will jump to the next buffer in the list (by adding the MAXCNT size to the buffer pointer).
You can enable the EasyDMA list feature in the driver by setting the flag NRFX_TWIM_FLAG_TX_POSTINC/NRFX_TWIM_FLAG_RX_POSTINC, but you will have to reserve/fill the consecutive data in the RAM buffers manually. Unfortunately, we do not have any sample code apart from the code in the above linked TWIM peripheral documentation.
Best regards,
Jørgen
Can you do this with 2 TWI instances?
In other words, can I have device 1 in TWI0 and device 2 in TWI1 and use EasyDMA + PPI, so I can do the direct transfer from each device without CPU intervention with, let's say, each device having a MAXCNT = 4096 bytes?
if not, what would be the ideal solution for collecting large chunks of data from 2 devices using TWI simultaneously without CPU intervention?
You can trigger transfers from two TWIM instances using PPI, but the max transfer size will depend on which chip you are using. nRF52832 support only 8-bit MAXCNT register for the TWIM peripheral. nRF52810 support 10 bit and nRF52840 support 16 bits. On nRF52832 you can use the EasyDMA Arraylist feature to transmitt/receive more data without CPU intervention (not bigger chunks, but more chunks).
Sorry. I meant in the same i2c bus, two different instances.
You will need two buses. Multi-master is not supported:
This TWIM is only able to operate as a single master on the TWI bus. Multi-master bus configuration is not supported.