2022-08-26 09:29 AM
void ADC_Driver_InitializeADC(void)
{
peripheralADC1Init();
ADC_Activate();
}
void peripheralADC1Init(void)
{
LL_ADC_SetTriggerFrequencyMode(ADC1, LL_ADC_TRIGGER_FREQ_HIGH);
// Structure for some features of ADC common parameters and multimode
LL_ADC_CommonInitTypeDef ADC_CommonInitStruct;
ADC_CommonInitStruct.CommonClock = LL_ADC_CLOCK_ASYNC_DIV4;
LL_ADC_CommonInit(__LL_ADC_COMMON_INSTANCE(ADC1), &ADC_CommonInitStruct);
// Structure for some features of ADC instance, 12-bits resolution
LL_ADC_InitTypeDef ADC_InitStruct;
ADC_InitStruct.Resolution = LL_ADC_RESOLUTION_12B;
ADC_InitStruct.LowPowerMode = LL_ADC_LP_MODE_NONE;
ADC_InitStruct.LeftBitShift = LL_ADC_LEFT_BIT_SHIFT_NONE;
LL_ADC_Init(ADC1, &ADC_InitStruct);
// Structure definition of some features of ADC group regular
LL_ADC_REG_InitTypeDef ADC_REG_InitStruct;
ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE;
ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_DISABLE;
ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE;
ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_SINGLE;
ADC_REG_InitStruct.Overrun = LL_ADC_REG_OVR_DATA_PRESERVED;
ADC_REG_InitStruct.DataTransferMode = LL_ADC_REG_DR_TRANSFER;
LL_ADC_REG_Init(ADC1, &ADC_REG_InitStruct);
}
ADC_Activate(void)
{
if (LL_ADC_IsEnabled(ADC1) == 0)
{
if(LL_ADC_IsActiveFlag_ADRDY(ADC1) == 1)
{
LL_ADC_ClearFlag_ADRDY(ADC1);
}
/* Enable ADC */
LL_ADC_Enable(ADC1);
while (LL_ADC_IsActiveFlag_ADRDY(ADC1) == 0)
{
}
}
}
void Channel1(void) // Will be using this based on the dependency
{
////
}
2022-08-26 10:22 AM
The reference manual says the ADC must be calibrated before use. Certainly that is true for accuracy.
I don't see an ADSTART bit set.
Cheers, Hal
2022-08-26 10:53 AM
2022-08-26 01:44 PM
Do a comparison with this example that comes with Cube:
NUCLEO-U575ZI-Q/Examples_LL/ADC/ADC_SingleConversion_TriggerSW
Cheers, Hal
2022-08-30 06:07 AM
Thanks for the suggestion @raptorhal2 ,
I'm referring the same example suggested by you and got a problem while calibration.
I'm setting the ADCCAL bit and it is not resetting ( As per the reference manual that bit should reset on its own when the Calibration is done and it's not happening in my case).
Any suggestion for this?
2022-08-30 08:43 AM
I am not familiar with the 575 and mildly familiar with LL programming.
The suggested example has substantial code for ADC setup delays. Review carefully to see if something is relevant there.
Cheers, Hal
2022-09-01 08:04 AM
Thanks for the reply and I'm using required delays.
When I try to enable the Voltage regulator(ADVREGEN = 1) but LDORDY bit that denotes that the Voltage regulator is running isn't set.
What might be the issue?
2022-09-22 07:49 AM
You need to enable the VDDA, see https://community.st.com/s/question/0D53W00001onmvQSAQ