2021-09-27 03:50 AM
Hello,
is there a way that a timer triggers an I2C-Receive with a Datatransfer from the Peripheral to memory via DMA?
I’d like to have no “Timer-Interrupt�? that calls the DMA-Transfer, invoking the I2C. I’d like to drive the DMA-Request from the Timer without CPU-intervention and just use the DMA-Comple-Callback.
Is that possible, and how can that be configured in the STM32CubeIDE?
Thanks a lot.
Best regards, Seppel
2021-09-27 04:02 AM
Do you mean Master Receiver?
Which STM32?
There are at least 2 very different I2C implementations in different STM32 families.
Generally, if you can start the Rx process simply by writing some value to some (I2C) register, then you can do the same transferring that value from memory to given I2C register using DMA triggered from timer.
JW
2021-09-27 04:18 AM
Hello,
Sure, a timer can trigger an DMA Transfer from a peripheral. However it makes much mir sense to navigate to the to the I2C config, select the "DMA Settings"-Tab and add a DMA Request triggered by I2C_RX. I havnt tried it yet, but I assume it works. Still triggering a timed I2C Transfer would require a Timer-Interrupt, which I'd like to avoid.
Tanks a lot.
Best Regards, Seppel
2021-09-27 05:55 AM
I don't think the hardware supports a periodic I2C receive without CPU intervention.
2021-09-27 07:17 AM
If I understood correctly, Seppel does not want to avoid code altogether - probably as an attempt to time some process in the sensor precisely, he would trigger the reception, and then prepare the next Rx in the DMA-TC interrupt.
This might be IMO viable in 'G4 I2C (in contrast to older I2C found e.g. in 'F1/'F2/'F4), after configuring other I2C registers and DMA, by a single write to I2C_CR2, to set START (and NBYTE and AUTOEND). That single write might be performed by the timer-triggered DMA.
This implies of course just a pure Rx to be used, i.e. no preceding Tx/ReSTART to set register address or similar.
JW
2021-09-27 08:08 AM
Hello,
what I’d like to avoid is Interrupts generated by the timer, so I avoid context-switches. It reduces jitter, saves CPU-cycles, etc. . However, if multiple sensors with different I2C-addresses need to be read, there may be no way to avoid that anyway.
I was just questioning if I missed something and you experts know more than I do.
Thanks a lot, best Regards, Seppel