Skip to content

Commit

Permalink
Increase ADC accuracy (#2126)
Browse files Browse the repository at this point in the history
increase sampling time and reduce oversampling
  • Loading branch information
robbederks authored Jan 22, 2025
1 parent 9066088 commit 3597071
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions board/stm32h7/lladc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ static uint16_t adc_get_raw(uint8_t channel) {
ADC1->SQR1 &= ~(ADC_SQR1_L);
ADC1->SQR1 = (uint32_t)channel << 6U;

ADC1->SMPR1 = 0x2UL << (channel * 3UL);
ADC1->SMPR1 = 0x4UL << (channel * 3UL);
ADC1->PCSEL_RES0 = (0x1UL << channel);
ADC1->CFGR2 = (127UL << ADC_CFGR2_OVSR_Pos) | (0x7U << ADC_CFGR2_OVSS_Pos) | ADC_CFGR2_ROVSE;
ADC1->CFGR2 = (63UL << ADC_CFGR2_OVSR_Pos) | (0x6U << ADC_CFGR2_OVSS_Pos) | ADC_CFGR2_ROVSE;

ADC1->CR |= ADC_CR_ADSTART;
while (!(ADC1->ISR & ADC_ISR_EOC));
Expand Down

0 comments on commit 3597071

Please sign in to comment.