Skip to content

[BUG] ESP32-S3 Stuck in adc functions #295

Closed
@CommanderRedYT

Description

@CommanderRedYT

Describe the bug
When trying for example the Inline current sensing test, the ESP32-S3 (esp32-s3-devkitc-1 v1.0), the esp32 is not printing anything. After some debugging, we discovered that it is stuck in adcRead (https://github.com/simplefoc/Arduino-FOC/blob/master/src/current_sense/hardware_specific/esp32/esp32s_adc_driver.cpp). We found that the while loop checking if the adc is ready is causing the problem (with our pin configuration, its the bottom one in line 241):

if(channel > 7){
while (GET_PERI_REG_MASK(SENS_SAR_MEAS2_CTRL2_REG, SENS_MEAS2_DONE_SAR) == 0); //wait for conversion
value = GET_PERI_REG_BITS2(SENS_SAR_MEAS2_CTRL2_REG, SENS_MEAS2_DATA_SAR, SENS_MEAS2_DATA_SAR_S);
} else {
while (GET_PERI_REG_MASK(SENS_SAR_MEAS1_CTRL2_REG, SENS_MEAS1_DONE_SAR) == 0); //wait for conversion
value = GET_PERI_REG_BITS2(SENS_SAR_MEAS1_CTRL2_REG, SENS_MEAS1_DATA_SAR, SENS_MEAS1_DATA_SAR_S);
}

When adding this line of code, I can see "reg: 80160000" inside the serial monitor:

Serial.printf("reg %x\n", READ_PERI_REG(SENS_SAR_MEAS1_CTRL2_REG));

Describe the hardware setup
For us it is very important to know what is the hardware setup you're using in order to be able to help more directly

  • Which motor: None (devboard only)
  • Which driver: None
  • Which microcontroller: Espressif ESP32-S3-DevKitC-1
  • Which position sensor: None
  • Current sensing used? Yes

IDE you are using

[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
lib_deps = askuric/Simple [email protected]
lib_archive = false
monitor_speed = 115200
upload_speed = 921600

We tried this with multiple esp32-s3 boards, and did not get it to work. When using this platformio configuration for normal esp32 (not S3!), it works however (same code):

[env:esp32dev]
platform = [email protected]
board = esp32dev
framework = arduino
lib_deps = askuric/Simple [email protected]
lib_archive = false
monitor_speed = 115200
upload_speed = 921600

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions