I'm using stm32u575ZI-Q and trying to configure the ADC using LL drivers and it isn't starting ON (ADCRDY =0), Need help on missing piece or mistake that I'm doing here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-08-26 9: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
{
////
}
- Labels:
-
ADC
-
STM32U5 series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-08-26 10:53 AM
- Calibration is must for Differential mode as they mentioned. But I'm using my ADC in single mode only.
- ADSTART is to start conversion.But BEFORE that ADCRDY should be set to ensure that ADC is enabled and it is done by writing ADEN bit even after writing it, ADCRDY bit is still 0. I feel I'm definitely missing something but couldn't find what it is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-08-26 1:44 PM
Do a comparison with this example that comes with Cube:
NUCLEO-U575ZI-Q/Examples_LL/ADC/ADC_SingleConversion_TriggerSW
Cheers, Hal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-08-30 6: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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-08-30 8: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-09-01 8: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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-09-22 7:49 AM
You need to enable the VDDA, see https://community.st.com/s/question/0D53W00001onmvQSAQ
