cancel
Showing results for 
Search instead for 
Did you mean: 

I2C Receive , triggered by a Timer, Datatransfer via DMA

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

5 REPLIES 5

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

Hello,

  • STM32G4
  • I2C Transfer from external Sensor(I2C-Slave) to STM32G4 (I2C-Master)

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

TDK
Guru

I don't think the hardware supports a periodic I2C receive without CPU intervention.

If you feel a post has answered your question, please click "Accept as Solution".

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

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