stm32/adc: Fix ADC clock prescaler for G4 MCUs.
For STM32G4, ADC clock frequency should be equal or less than 60MHz. To satisfy this specification, ADC clock prescaler should be equal or greater than 4 (For example, NUCLEO_G474RE runs 170MHz). In addition, to obtain accurate internal channel value, the ADC clock prescaler is set to 16 because vbat needs at least 12us (16/170*247.5=23.3us). Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
This commit is contained in:
parent
ec9ea97413
commit
de8035b510
@ -344,7 +344,11 @@ STATIC void adcx_init_periph(ADC_HandleTypeDef *adch, uint32_t resolution) {
|
|||||||
adch->Init.DataAlign = ADC_DATAALIGN_RIGHT;
|
adch->Init.DataAlign = ADC_DATAALIGN_RIGHT;
|
||||||
adch->Init.DMAContinuousRequests = DISABLE;
|
adch->Init.DMAContinuousRequests = DISABLE;
|
||||||
#elif defined(STM32G0) || defined(STM32G4) || defined(STM32H5) || defined(STM32L4) || defined(STM32WB)
|
#elif defined(STM32G0) || defined(STM32G4) || defined(STM32H5) || defined(STM32L4) || defined(STM32WB)
|
||||||
|
#if defined(STM32G4)
|
||||||
|
adch->Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV16;
|
||||||
|
#else
|
||||||
adch->Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
|
adch->Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
|
||||||
|
#endif
|
||||||
adch->Init.ScanConvMode = ADC_SCAN_DISABLE;
|
adch->Init.ScanConvMode = ADC_SCAN_DISABLE;
|
||||||
adch->Init.LowPowerAutoWait = DISABLE;
|
adch->Init.LowPowerAutoWait = DISABLE;
|
||||||
adch->Init.Overrun = ADC_OVR_DATA_PRESERVED;
|
adch->Init.Overrun = ADC_OVR_DATA_PRESERVED;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user