Skip to content

Commit 2200504

Browse files
committed
s3 bugfix - it cannot read faster than 10us per adc sample
1 parent 910c24f commit 2200504

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/current_sense/hardware_specific/esp32/esp32_mcpwm_mcu.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,6 @@
2828
#include "driver/gpio.h"
2929

3030

31-
// if the MCU is not ESP32S3, the ADC read time is too long to
32-
// sample all three phase currents in one interrupt
33-
// so we will sample one phase per interrupt
34-
#ifdef CONFIG_IDF_TARGET_ESP32S3
35-
#define SIMPLEFOC_SAMPLE_ONCE_PER_INTERRUPT
36-
#endif
37-
38-
3931
#ifdef CONFIG_IDF_TARGET_ESP32S3
4032
#define DEBUGPIN 16
4133
#define GPIO_NUM GPIO_NUM_16
@@ -181,17 +173,12 @@ void* _driverSyncLowSide(void* driver_params, void* cs_params){
181173
gpio_set_level(GPIO_NUM,1); //cca 250ns for on+off
182174
#endif
183175

184-
#ifdef SIMPLEFOC_SAMPLE_ONCE_PER_INTERRUPT // sample the phase currents one at a time
185-
// ex. ESP32's adc read takes around 10us which is very long
176+
// sample the phase currents one at a time
177+
// ESP's adc read takes around 10us which is very long
186178
// increment buffer index
187179
p->buffer_index = (p->buffer_index + 1) % p->no_adc_channels;
188180
// so we are sampling one phase per call
189181
p->adc_buffer[p->buffer_index] = adcRead(p->pins[p->buffer_index]);
190-
#else // sample all available phase currents at once
191-
// ex. ESP32S3's adc read takes around 1us which is good enough
192-
for(int i=0; i < p->no_adc_channels; i++)
193-
p->adc_buffer[p->buffer_index] = adcRead(p->pins[p->buffer_index]);
194-
#endif
195182

196183
#ifdef SIMPLEFOC_ESP32_INTERRUPT_DEBUG // debugging toggle pin to measure the time of the interrupt with oscilloscope
197184
gpio_set_level(GPIO_NUM,0); //cca 250ns for on+off

0 commit comments

Comments
 (0)