STM32 ADC & DMA corrupted Values

Guest #6880360
Rate this post
useful
not useful
Hi Forum

I use adc with dma on different stm32-mcus.
i try to sample 3 channels in continous mode with a long buffer to 
filter later.
this all works as long as there is no additional interrupt.

i set up the system with highest priority for dma(0), but lowesd for 
I2c(3) in NVIC.

What happens:

the order of the adc values in Memory changes for no reason.
1
Value 1 -> Battery Voltage -> adcRawMemory[0]
2
Value 2 -> External Poti -> adcRawMemory[1]
3
Value 3 -> Temperature -> adcRawMemory[2]
4
Value 1 -> Battery Voltage -> adcRawMemory[3]
5
Value 2 -> External Poti -> adcRawMemory[4]
6
Value 3 -> Temperature -> adcRawMemory[5]

after some intterupts on i2c the order changes:
1
Value 1 -> Battery Voltage -> adcRawMemory[1]
2
Value 2 -> External Poti -> adcRawMemory[2]
3
Value 3 -> Temperature -> adcRawMemory[3]
4
Value 1 -> Battery Voltage -> adcRawMemory[4]
5
Value 2 -> External Poti -> adcRawMemory[5]
6
Value 3 -> Temperature -> adcRawMemory[6]

I also see this behavior with the iwd activated...

any one has some fundametal hints to this problem?
Is there any syncronisation issue in the stm32 core that needs to be 
addressd when using ADC with DMA?

Rebell
Guest #6880433
Rate this post
useful
not useful
Lothar M. wrote:
>> after some intterupts on i2c the order changes:
> How long is your "adcRawMemory" buffer? Does it "wrap around"
> autmatically?
>
>> any one has some fundametal hints to this problem?
> Did an error occur on the I2C bus meanwhile?

Hi Lothar

adcRawMemory is 288 Bytes and im sampling 6 channels.

I2C Bus error could happen ... i have to check. whats the outcome if 
there is an error?

>Are you using an STMF103C8xx or STM32F103CBxx? I am asking because the
>web is full of negative reports about fake products with wrong data
>transferred by DMA.

the mcus are from the STM32F0xx and STM32G4xx Family. they should be 
genuine, they ar from the time bevor the chipcrisis :-)

thanks, Rebell
Guest #6880464
Rate this post
useful
not useful
So what can cause such a "moving"?

ADC and DMA should be independent to any other CPU-driven actions right?
only the DMA can stopp the CPU from accessing the same BUS at the same 
Time when DMA is writing the Values to Mamory.

how can a CPU-driven action compromise the DMA-Pointer or the ADC 
Channel selsction? (of corse without writing to this specific registers 
...)

Rebell
Guest #6881559
Rate this post
useful
not useful
So my guess is:

dma uses the the APB bus for Transfering ADC Values to Memory.

When an I2C-Interrupt occures the APB Bus may be accessed from CPU and 
therfore an access fom DMA is not possible or delayed.

whats the access priority here? i'm not to deep into the architecture 
from STM here...

could the source of this problem a timing issue on the Bus be?

Rebell
Attached files:

Reply

Please log in before posting.

or

Log in with Google account

Registration is free and takes only a minute.

Register now