2018-01-23 07:15 AM
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 #stm32Solved! Go to Solution.
2018-01-25 12:32 AM
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
2018-01-23 02:37 PM
Did you use the cube ?
Some engineers dont like the cube, but for us
newbie
s, cube works very well.2018-01-24 12:53 PM
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
2018-01-25 12:32 AM
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