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.

1 ACCEPTED SOLUTION

Accepted Solutions

When I checked the library, I checked the contents related to interrupt. I should find another way. Thank you.

View solution in original post

5 REPLIES 5
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.

TDK
Super User

If something is using DMA, it will function at the same time as the interrupt. The IRQ will not stop or pause it.

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

@giwonKIM Does the STM32 pause clocking on the I2C while the other interrupt handler executes?

The I2C transfer on STM32 unfortunately has several steps, some of them use interrupts (even polling IIRC), so what you see is possible. For more details please check the library source.

 

When I checked the library, I checked the contents related to interrupt. I should find another way. Thank you.