AnsweredAssumed Answered

ADC not ready after enable (ADRDY bit)

Question asked by Damiano Balzani on Jan 23, 2018
Latest reply on Jan 25, 2018 by Damiano Balzani

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);

Outcomes