Skip to content

Commit ba432cb

Browse files
committed
no offset for f1
1 parent 7eedddf commit ba432cb

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

src/current_sense/hardware_specific/stm32/stm32_adc_utils.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,14 @@ float _readRegularADCVoltage(const int pin){
605605

606606
ADC_ChannelConfTypeDef sConfig = {0};
607607
sConfig.Channel = last_channel[adc_index];
608+
// the shortes possible sampling time
609+
// this seems to be a constant in HAL - the shortest time enum is equal to 0
610+
// G4 - 2.5 cycles
611+
// F1, H7 - 1.5 cycles
612+
// L4 - 2.5 cycles
613+
// F4, F7 - 3 cycles
614+
sConfig.SamplingTime = 0;
615+
608616
#ifdef ADC_REGULAR_RANK_1
609617
sConfig.Rank = ADC_REGULAR_RANK_1;
610618
#else
@@ -616,15 +624,10 @@ float _readRegularADCVoltage(const int pin){
616624
#ifdef ADC_OFFSET_NONE
617625
sConfig.OffsetNumber = ADC_OFFSET_NONE;
618626
#endif
619-
// the shortes possible sampling time
620-
// this seems to be a constant in HAL - the shortest time enum is equal to 0
621-
// G4 - 2.5 cycles
622-
// F1, H7 - 1.5 cycles
623-
// L4 - 2.5 cycles
624-
// F4, F7 - 3 cycles
625-
sConfig.SamplingTime = 0;
627+
#ifndef STM32F1xx
626628
sConfig.Offset = 0;
627-
629+
#endif
630+
628631
if (HAL_ADC_ConfigChannel(&hadc[adc_index], &sConfig) != HAL_OK) {
629632
#ifdef SIMPLEFOC_STM32_DEBUG
630633
SIMPLEFOC_DEBUG("STM32-CS: ERR: Failed to configure regular channel");

0 commit comments

Comments
 (0)