Работа с прерываниями на ESP32

Пишу алгоритм машинки с обходом препятствий, ее задача сканировать состояние 3 оптических датчиков и если есть есть столкновение развернуться. Я смог реализовать прерывания и обход препятствий при столкновение, но не смог в спокойном состояние заставить ехать. Почитал информацию о том, что при срабатывание прерывания loop останавливается и начинает работать наша функция. Но в реалии он в loop едет вперед и при срабатывание датчиков его поведение не меняется. Пробовал и другие варианты, но у меня кидает ошибку

Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1)

Установка статуса пинов

  ledcSetup(0, 50, 8);
  ledcAttachPin(leftWheelForwardPIN, 0);
  ledcAttachPin(rightWheelForwardPIN, 1);
  ledcAttachPin(leftWheelBackwardPIN, 2);
  ledcAttachPin(rightWheelBackwardPIN, 3);
  pinMode(leftWheelForwardPIN, OUTPUT);
  pinMode(rightWheelForwardPIN, OUTPUT);
  pinMode(leftWheelBackwardPIN, OUTPUT);
  pinMode(rightWheelBackwardPIN, OUTPUT);
  pinMode(laserSensorLeftPIN, INPUT_PULLUP);
  pinMode(laserSensorCenterPIN, INPUT_PULLUP);
  pinMode(laserSensorRightPIN, INPUT_PULLUP);
  pinMode(countRotationLeftPIN, INPUT_PULLUP);
  pinMode(countRotationRightPIN, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(laserSensorLeftPIN), laserLeftFunction, FALLING  );
  attachInterrupt(digitalPinToInterrupt(laserSensorCenterPIN), laserCenterFunction, FALLING  );
  attachInterrupt(digitalPinToInterrupt(laserSensorRightPIN), laserRightFunction, FALLING  );
  attachInterrupt(digitalPinToInterrupt(countRotationLeftPIN), countLeftFunction, FALLING);
  attachInterrupt(digitalPinToInterrupt(countRotationRightPIN), countRightFunction, FALLING);

Функции уклонения от столкновения

void IRAM_ATTR laserLeftFunction() {
  if (drive == true) {
    ledcWrite(1, 0);
    ledcWrite(2, 0);
    ledcWrite(3, 0);
    ledcWrite(0, 255);
  }
}

void IRAM_ATTR laserCenterFunction() {
  if (drive == true) {
    ledcWrite(1, 0);
    ledcWrite(3, 0);
    ledcWrite(0, 255);
    ledcWrite(2, 255);
  }
}

void IRAM_ATTR laserRightFunction() {
  if (drive == true) {
    ledcWrite(0, 0);
    ledcWrite(2, 0);
    ledcWrite(3, 0);
    ledcWrite(1, 255);
  }
}

Функция движения вперед

void loop() {
  if (drive) {
    ledcWrite(2, 0);
    ledcWrite(3, 0);
    ledcWrite(0, speedLeft);
    ledcWrite(1, speedRight);
  } else {
    ledcWrite(1, 0);
    ledcWrite(2, 0);
    ledcWrite(3, 0);
    ledcWrite(0, 0);
  }
}
 

Ответы (0 шт):