cancel
Showing results for 
Search instead for 
Did you mean: 

ADC not ready after enable (ADRDY bit)

Damiano Balzani
Associate III
Posted on January 23, 2018 at 16:15

Hi everybody,

i'm using the ADC on STM32L051.

After enable operation (ADEN = 1) it will not be ready never (ADRDY bit).

I put my code here

Can you help me?

thanks in advance

Damiano

RCC->APB2ENR = RCC->APB2ENR | 0x200; //ADC Clock enable

ADC1 -> CFGR1 |= 0x00008000; //ADC Auto-off enable

if((LL_ADC_IsEnabled(ADC1) == 1) | (!(LL_ADC_REG_GetDMATransfer(ADC1) == LL_ADC_REG_DMA_TRANSFER_NONE))) //if AD and DMA are enabled

{

LL_ADC_Disable(ADC1);

LL_ADC_REG_SetDMATransfer(ADC1, LL_ADC_REG_DMA_TRANSFER_NONE);

}

LL_ADC_StartCalibration(ADC1); //Calibration enabled

while(LL_ADC_IsCalibrationOnGoing(ADC1)==1)

{

//Add timeout code

}

cal_fact = LL_ADC_GetCalibrationFactor(ADC1);

//read ADC -> to move from here

LL_ADC_SetClock(ADC1, LL_ADC_CLOCK_SYNC_PCLK_DIV1);

LL_ADC_SetSamplingTimeCommonChannels(ADC1, LL_ADC_SAMPLINGTIME_7CYCLES_5);

LL_ADC_SetResolution(ADC1, LL_ADC_RESOLUTION_12B);

//LL_ADC_REG_SetSequencerScanDirection(ADC1, LL_ADC_REG_SEQ_SCAN_DIR_FORWARD);

LL_ADC_SetDataAlignment(ADC1, LL_ADC_DATA_ALIGN_RIGHT);

LL_ADC_REG_SetSequencerChannels(ADC1, LL_ADC_CHANNEL_6);

LL_ADC_REG_SetContinuousMode(ADC1, LL_ADC_REG_CONV_SINGLE);

LL_ADC_ClearFlag_ADRDY(ADC1);

LL_ADC_Enable(ADC1);

while(!LL_ADC_IsActiveFlag_ADRDY(ADC1))

{

}

LL_ADC_REG_StartConversion(ADC1);

#stm32-stm32cube #adrdy #stm32
1 ACCEPTED SOLUTION

Accepted Solutions
Damiano Balzani
Associate III
Posted on January 25, 2018 at 09:32

i've found the problem.

There is the auto-off enable before start the calibration. It blocks the calibration process.

Now i've removed it and the calibration starts!

Thanks for help

Damiano

View solution in original post

3 REPLIES 3
T J
Lead
Posted on January 23, 2018 at 23:37

Did you use the cube ?

Some engineers dont like the cube, but for us

newbie

s, cube works very well.
Posted on January 24, 2018 at 21:53

I don't know if it answers your question but in this thread

https://community.st.com/0D50X00009XkaB8SAJ

or threads linked from there may be some relevant issues discussed (sorry I can't check because of the forum being in havoc, but maybe you can see that thread).

JW

Damiano Balzani
Associate III
Posted on January 25, 2018 at 09:32

i've found the problem.

There is the auto-off enable before start the calibration. It blocks the calibration process.

Now i've removed it and the calibration starts!

Thanks for help

Damiano