cancel
Showing results for 
Search instead for 
Did you mean: 

i2c dma question

giwonKIM
Associate III

Hi i'm using STM32F411RE.

 

I've been reading data from ADC IC using I2C communication. It's 400Khz, and I'm reading using DMA.

By the way, if another interrupt with high priority occurs during I2C communication, it runs that interrupt during I2C communication and reads I2C data again.

If I operate with DMA, isn't it irrelevant to the interrupt because I2C operates on hardware?

 

Of course, the data comes exactly.

 

If you have any question, please ask me.

 

Thank you.

2 REPLIES 2
Andrew Neil
Super User

@giwonKIM wrote:

if another interrupt with high priority occurs during I2C communication, it runs that interrupt during I2C communication and reads I2C data again. .


Not sure what you mean by that?

Perhaps show a minimum but complete example which illustrates this.

 


@giwonKIM wrote:

Of course, the data comes exactly.


So there isn't actually any problem?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Ozone
Principal II

As @Andrew Neil  pointed out, the question is not very comprehensible.

... if another interrupt with high priority occurs during I2C communication, it runs that interrupt during I2C communication and reads I2C data again.

How would you know it reads again ?
Except you have a DMA interrupt activated that would notify you.

Unless you need equidistant samples, you can transfer the ADC values to some memory location via DMA in the background, and read them when convenient.

Otherwise (i.e. equidistance is required) you could transfer a larger number of samples, and activate a DMA TC interrupt.
You would need to copy the ADC buffer data in the interrupt handler, since DMA would begin to overwrite it.

Prioritisation within the context of other interrupts are your responsibility.