cancel
Showing results for 
Search instead for 
Did you mean: 

I2C DMA function... help me to make code... and working..

mkim.51
Associate II

I am using Stm32F411RCT chip

and using BMP280 pressure sensor * 2 ea and hdc1080 * 1ea.

I made the code for three sensors to act as a polling.

however,

in order to reduce the amount of time that data is read and written,

I am changing that function from polling to DMA.

I'm struggling because it's not easy to change.

I read the AN2824 Application note about I 2 C optimised examples.

in 10 pages,

Master transmitter

DMA requests are generated only for data transfer. In transmission, DMA requests are

generated by the Data Register becoming empty (TXE = 1).

All remaining events (SB, ADDR, etc.) must be managed by polling or interrupts. In the

examples accompanying this application note, they are managed by polling.

The master sends the START condition on the bus by setting START bit. The interface waits

for the SB flag to be set and then cleared by writing the slave address in DR register. The

interface waits for ADDR flag to be set then cleared by reading SR1 and SR2 status register.

At that point, DMA transfers begin

I have to make the codes for ALL REMAINING EVENTS (SB , ADDR, etc..) using ISR

however,

I really don't know what to do.

I'm really sorry, but I wish you could help me make code. I beg you.

2 REPLIES 2

>>however, in order to reduce the amount of time that data is read and written, I am changing that function from polling to DMA.

A couple of devices, on the same bus, transacting a handful of bytes. What kind of net benefit do you feel this is going to have over an interrupt based sequencer? These aren't memories pushing a few hundred contiguous bytes per transaction.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

It takes 1 ms to read and write the bmp280 * 2ea and 0.2 ms to read and write the hdc1080 in while.

My system period is approximately 40 ms and my algorithm for taking and turning the microphone and sensor data is approximately 30 ms.

I'm working with a co-worker who wants me to run i2c on a dma.

I honestly don't know how fast the i2c will get when I change it to dma and I don't know the expected effect.