Esp32 crash freeRTOS

i try to run a task with freeRTOS but esp32 crash,

void setup() {

  Serial.begin(9600);                            // PC Serial monitor

  pinMode(NPN_GSM_reset, OUTPUT);
  digitalWrite(NPN_GSM_reset, HIGH);  //GSM ON

  pinMode(NPN_mp3, OUTPUT);
  digitalWrite(NPN_mp3, HIGH);  //MP3 ON

  pinMode(NPN_motor_M1, OUTPUT);
  pinMode(NPN_led_L1, OUTPUT);
  pinMode(NPN_led_L2, OUTPUT);
  pinMode(NPN_led_L3, OUTPUT);

  // Bluetooth Start
  ble_serial.begin("ar_" + skuID);  // Initialize Bluetooth with a specific name
  debug_print(1, "BLE START");

  xTaskCreate(
    task1,    // Task function pointer (the function that defines the task's behavior)
    "Task1",  // A descriptive name for the task
    1000,     // Stack depth in words (e.g., 1000 words for the task's stack)
    NULL,     // Task parameter (can be used to pass data to the task; set to NULL in this example)
    1,        // Task priority higher numbers represent higher priority.
    NULL      // Task handle (used to reference the task; set to NULL in this example)
  );
}


void task1(void *parameter) {
  if (status_driving == 1) {
    byte throttle_IN = analogRead(GPIO_throttle_IN_V1);
    if (throttle_IN > max_speed) {  //speed limit
      throttle_IN = max_speed;
    }

    byte throttle_out = map(throttle_IN, 12, 45, 3, 55);  //convert: throttle_input_min_val, max_val, throttle_output_min_val, max_val

    if (throttle_IN < 13) {
      throttle_out = 0;
    }

    if (actual_speed != throttle_out) {
      // dacWrite(DAC2, throttle_out);  // Set the initial DAC value to 0
      ledcWrite(0, throttle_out);  // Set the initial DAC value to 0
    }

    byte brake_count = 0;
    while (digitalRead(GPIO_brake_IN_V2) == HIGH && brake_count < 10) { 
      digitalWrite(NPN_led_L3, LOW);
      delay(100);
      digitalWrite(NPN_led_L3, HIGH);
      delay(100);
      brake_count++;
    }

    vTaskDelay(pdMS_TO_TICKS(1000));  // Delay for 1 second
  } else {

    if (status_led2 == 0) {
      digitalWrite(NPN_led_L2, HIGH);
      status_led2 = 1;
    } else {
      digitalWrite(NPN_led_L2, LOW);
      status_led2 = 0;
    }

    vTaskDelay(pdMS_TO_TICKS(2000));  // Delay for 2 second
  }
}

void loop() {

  //PC SERIAL
  if (Serial.available() > 0) {
    String cmd = Serial.readStringUntil('\n');
    cmd.trim();
    func1(cmd);
  }
func2();
func3();
  //PC SERIAL
}

Rebooting...
BLE START
Guru Meditation Error: Core 0 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x400d23a0: 65e8a3a2 f01dc3da c0f72321
Core 0 register dump:
PC : 0x400d23a6 PS : 0x00060b30 A0 : 0x00000000 A1 : 0x3ffe2d40
A2 : 0x3ffc3238 A3 : 0x00000001 A4 : 0x00000000 A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x800d23a6 A9 : 0x3ffe2d20
A10 : 0x000007d0 A11 : 0x3ffbf3d8 A12 : 0x00000014 A13 : 0x00000000
A14 : 0x3ffe2ddc A15 : 0x80000001 SAR : 0x0000001b EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
Backtrace: 0x400d23a3:0x3ffe2d40
ELF file SHA256: e4a03b3dbd565dc4

usually a task has some kind of infinite loop built in

void vTaskCode( void * pvParameters )
{
    for( ;; )
    {
        /* Task code goes here. */
    }
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.