cancel
Showing results for 
Search instead for 
Did you mean: 

ADC/DMA one off problem

mrost9
Associate II
Posted on April 06, 2010 at 10:38

ADC/DMA one off problem

4 REPLIES 4
Posted on May 17, 2011 at 13:46

Sounds like you are glitching the DMA while you are setting up the ADC, and changing the settings. Perhaps you should get everything set up properly *before* enabling the DMA to accept transfers?

This should be less prone to that

    ADC_StartCalibration(ADC1);

    while(ADC_GetCalibrationStatus(ADC1));

    /* Enable DMA1 channel1 */

    DMA_Cmd(DMA1_Channel1, ENABLE);

    ADC_SoftwareStartConvCmd(ADC1, ENABLE);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mrost9
Associate II
Posted on May 17, 2011 at 13:46

Thanks, that sounds logical.

I didn't think of it as a possible problem, as the ADCx_DMA examples do it in the same order.

I'll try it.

daviddavid942
Associate II
Posted on May 17, 2011 at 13:46

Hi,

Clive1 is right... as usual 😉

I had the same problem few weeks ago and changed the initialization order given in the example. The ''array swapping values'' phenomenon disappeared.

mrost9
Associate II
Posted on May 17, 2011 at 13:46

By chance I just saw, that the problem occurs reliably when the STM resets itself.

(Usually I turn power off and on, that's why I couldn't reproduce it.)

So I guess, either ADC or DMA are not completely reset by my initialisation code.

But shouldn't the periphereals not be reset by this code?

<code>

void ResetSTM32()

{

    SCB->AIRCR = 0x05FA0000 | SCB_AIRCR_VECTRESET;        // resets periphereals only

    SCB->AIRCR = 0x05FA0000 | SCB_AIRCR_SYSRESETREQ;    // resets the core

}

</code>

just wondering....

EDIT: Confirmed.

Adding ADC_DeInit(ADC1); before ADC_Init really helps.