Stable ADC on H7 (#1540)

* 256x oversampling

* reduce to 128x

* fix misra

---------

Co-authored-by: Comma Device <device@comma.ai>
This commit is contained in:
Robbe Derks
2023-08-01 20:48:10 -07:00
committed by GitHub
parent a945053ade
commit b4700a876f

View File

@@ -18,12 +18,12 @@ void adc_init(void) {
}
uint16_t adc_get_raw(uint8_t channel) {
ADC1->SQR1 &= ~(ADC_SQR1_L);
ADC1->SQR1 = ((uint32_t) channel << 6U);
ADC1->SMPR1 = (0x7U << (channel * 3U) );
ADC1->SMPR1 = (0x2U << (channel * 3U));
ADC1->PCSEL_RES0 = (0x1U << channel);
ADC1->CFGR2 = (127U << ADC_CFGR2_OVSR_Pos) | (0x7U << ADC_CFGR2_OVSS_Pos) | ADC_CFGR2_ROVSE;
ADC1->CR |= ADC_CR_ADSTART;
while (!(ADC1->ISR & ADC_ISR_EOC));