Skip to content

The IMU (MPU6886) does not work properly when running on a different core using FreeRTOS  #120

@meltingrabbit

Description

@meltingrabbit

When changing the execution core of the task to read IMU (MPU6886) values using xTaskCreatePinnedToCore from 1 to 0, the correct value cannot be read from the IMU.

In the sample code below, if you swap lines 20 and 21, it works or doesn't work properly.

#include <M5StickC.h>
#include <esp_task.h>

void multitask_imu(void* arg) {
  static int16_t x,y,z;
  while (1) {
    M5.IMU.getAccelAdc(&x,&y,&z);
    Serial.printf ("%d,%d,%d\n", x, y, z);
  }
}

void setup() {
  M5.begin();
  M5.IMU.Init();
  Serial.begin(115200);

  disableCore0WDT();
  disableCore1WDT();

  xTaskCreatePinnedToCore(multitask_imu, "Task0", 512*4, NULL, ESP_TASK_PRIO_MAX, NULL, 0);
  // xTaskCreatePinnedToCore(multitask_imu, "Task0", 512*4, NULL, ESP_TASK_PRIO_MAX, NULL, 1);

  delay(1000);
}

void loop() {
  delay(10000);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions