initFOC blocks ESP32 Serial

I am working with Adafruit ESP32 S3, AS5048B and SimpleFOC board with a gimbal motor. So far I have tested the sensor to work perfectly. The moment I do motor.initFOC, my computer don’t even see the any USB devices anymore. USB communication with ESP32 stops. What am I doing wrong?

#include <Arduino.h>
#include <SimpleFOC.h>
#include <Wire.h>

// Define the sensor object for AS5048B
// MagneticSensorI2C(uint8_t _chip_address, float _cpr, uint8_t _angle_register_msb)
MagneticSensorI2C sensor = MagneticSensorI2C(0x44, 14, 0xFE, 8); 
// My motor is a BDUAV-2204-260kv, a little gimbal motor, 7 pole pairs, 
// phase resistance = 10 ohms
BLDCMotor motor = BLDCMotor(7, 10);
// Motor driver and initialization
BLDCDriver3PWM  driver = BLDCDriver3PWM (5, 6, 9, 10); // Pins for the motor driver 


void setup() {

  driver.voltage_power_supply = 12; // driver config
  driver.init(); // power supply voltage [V]

  sensor.init(); // Initialize the sensor

  motor.linkSensor(&sensor); // link the sensor to the motor
  motor.linkDriver(&driver); // link the driver to the motor

  // aligning voltage
  motor.voltage_sensor_align = 3;
  
  // choose FOC modulation
  motor.foc_modulation = FOCModulationType::SpaceVectorPWM;

  // set torque mode
  motor.torque_controller = TorqueControlType::voltage;
  // set motion control loop to be used
  motor.controller = MotionControlType::torque;

  // initialize motor
  motor.init();
  // align sensor and start FOC
  //motor.initFOC();

  delay(1000);

}

// target voltage to be set to the motor
float target_voltage = 2;

void loop() {
  // Update sensor reading
  sensor.update();

  // Output angle
  Serial.print("Angle (rad): ");
  Serial.print(sensor.getAngle());
  Serial.print(" | Velocity (deg/s): ");
  Serial.println(sensor.getVelocity()); // Output velocity

  // main FOC algorithm function
  //motor.loopFOC();

  // Motion control function
  //motor.move(target_voltage);

  delay(1000); // update rate
}

It could be that you’re having an issue with the framework version and the library version… there’s been a lot of problems recently, especially with the S3 due to the IDF version upgrades.

You could try the dev branch version of the library, there have been some fixes related to the ESP32 issues…