ADS1115 and ESP32

Hello,

My configuration is :

M5Stack Core (ESP32)
PlatformIO

The configuration of my ADS1115 is correct.
My code works without FreeRTOS

When I run my program. ESP reboots automatically. Here is an excerpt from my code.

Can you help me ???

Tanks.

Pierre

xTaskCreatePinnedToCore(
                task420mA,     /* Function to implement the task */
                "task420mA",   /* Name of the task */
                10000,      /* Stack size in words */
                NULL,      /* Task input parameter */
                0,         /* Priority of the task */
                NULL,      /* Task handle. */
                0);        /* Core where the task should run */   ```


void task420mA( void * pvParameters ) {

  for(;;) {
           	Serial.println(ads.readADC_Differential_0_1());
           
               delay(1000);

              } // fin for
} // fin task 420mA```

It will be hard to determine from a few lines of code. Have you looked through this page: https://freertos.org/FAQHelp.html - it contains a collection of debugging features and tips.

Probably not the problem, but note you are allocating 10,000 words, or 40KBytes as the task’s stack - that seems excessive.

What does the ESP give as the reason for the reboot?

If you put a break point at the beginning of your task does it ever get hit? If so, can you step through the function to see how far it gets?

Is it valid to call delay() - what does it do? I would expect to see a call to vTaskDelay().

Hello Richard,

Thank you for your quick reply.

I looked in the FAQ but couldn’t find an answer.

PlatformIo does not have a debuq mode with M5Stack. :

Debugging currently does not support M5Stack Core ESP32 board.

I adapted my code with your comments but it doesn’t work

Here is the ESP error message:

[D][esp32-hal-i2c.c:1344] i2cProcQueue():  Busy Timeout start=0x29d4, end=0x2a06, =50, max=50 error=1
[E][esp32-hal-i2c.c:318] i2cDumpI2c(): i2c=0x3ffbdd54
[I][esp32-hal-i2c.c:319] i2cDumpI2c(): dev=0x60013000 date=0x16042000
[I][esp32-hal-i2c.c:321] i2cDumpI2c(): lock=0x3ffb8604
[I][esp32-hal-i2c.c:323] i2cDumpI2c(): num=0
[I][esp32-hal-i2c.c:324] i2cDumpI2c(): mode=1
[I][esp32-hal-i2c.c:325] i2cDumpI2c(): stage=3
[I][esp32-hal-i2c.c:326] i2cDumpI2c(): error=1
[I][esp32-hal-i2c.c:327] i2cDumpI2c(): event=0x3ffb8668 bits=0
[I][esp32-hal-i2c.c:328] i2cDumpI2c(): intr_handle=0x3ffb869c
[I][esp32-hal-i2c.c:329] i2cDumpI2c(): dq=0x3ffdf100
[I][esp32-hal-i2c.c:330] i2cDumpI2c(): queueCount=1
[I][esp32-hal-i2c.c:331] i2cDumpI2c(): queuePos=0
[I][esp32-hal-i2c.c:332] i2cDumpI2c(): errorByteCnt=0
[I][esp32-hal-i2c.c:333] i2cDumpI2c(): errorQueue=0
[I][esp32-hal-i2c.c:334] i2cDumpI2c(): debugFlags=0x00000000
[I][esp32-hal-i2c.c:311] i2cDumpDqData(): Debug Buffer not Enabled
[I][esp32-hal-i2c.c:354] i2cDumpInts(): Debug Buffer not Enabled
[I][esp32-hal-i2c.c:1138] i2cProcQueue(): Bus busy, reinit

I can be an explanation.

The readADC function instructs the ADC to read a voltage on the desired pin.
Then readADC waits for this value to be ready (since it takes some time for an ADC to convert an analog value present on one of its pins, into a digital value)
and finally, readADC retrieves this value, to be able to communicate it to us.

I tried with a Semaphore but still not good.
I read the doc of the FreeRTOS page " xSemaphoreTake"

Do you have an idea ?

Thanks in advance.

Pierre

Pierre, please answer this question of Richard. To even take a remote guess as to what is happening, we need to know how far in your system setup you get. When you single step through the code, do you ever get as far as vTaskScheduler()? If yes, does your timer interrupt get invoked at all? And the task function as Richard asked? Which memory manager do you use and how much memory do you have available? Do you ever get to a call to pvPortMalloc()?

You should first try to get a rough understanding of how FreeRTOS gets initialized and a system under FreeRTOS works. A lot of questions answer themselves at that point.