Page 1 of 1

How to generate interruptions with a 100us timer?

Posted: Wed Apr 03, 2024 3:38 pm
by walter.paz
Hellos everyone,

I'm using the function from the documentation of the freertos/timer.h library to generate interruptions with a timer. The configuration is as follows.

Code: Select all

bool timerInit(void)
{
    xTimers = xTimerCreate("Timer",                   // Nombre de la tarrea de timer.
                           (pdMS_TO_TICKS(muestreo)), // Periodo del timer en ticks.
                           pdTRUE,                    // El timer se autocargara un valor al llegar al conteo de ticks.
                           (void *)timerId,           // Identificador del timer
                           vTimerCallback             // Funcion a llammar cuando se ejecute la interrupcion
    );

    if (xTimers == NULL)
    {
        ESP_LOGI(tag, "Fallo en la inicializacion del timer");
    }
    else
    {
        if (xTimerStart(xTimers, 0) != pdPASS)
        {
            ESP_LOGI(tag, "Fallo en la activacion del timer");
        }
    }

    return true;        //Retorno true si todo es correcro
}
Then, I used the vTimerCallback function to place everything I want to execute inside. The code works perfectly without issues, but I believe it can only generate interruptions in the order of milliseconds. However, I need interruptions in microseconds. How can I create interruptions in microseconds with an ESP32-WROOM-32?

Regards.

Re: How to generate interruptions with a 100us timer?

Posted: Thu Apr 04, 2024 2:44 am
by ESP_Sprite
You'd use the high precision timer, or if getting the interrupts in time is really important, one of the hardware timers.

Re: How to generate interruptions with a 100us timer?

Posted: Fri Apr 05, 2024 5:07 pm
by walter.paz
Thank you for the suggestion. In fact, I've reviewed the Espressif documentation and I believe I managed to use the GPTimer, but I have an issue with the watchdog. The ESP32 restarts, and I encounter a strange message indicating that the watchdog reset CPI0 and CPU1. I don't have the message now, but essentially it says something like that. How can I solve this problem and deactivate the watchdog?

Re: How to generate interruptions with a 100us timer?

Posted: Sat Apr 06, 2024 5:38 am
by ESP_Sprite
walter.paz wrote:
Fri Apr 05, 2024 5:07 pm
How can I solve this problem and deactivate the watchdog?
Please don't shoot the messenger watchdog; it probably barks because you're doing stuff in your gptimer interrupt that you're not supposed to do. You can post the code so we can get an idea, but generally you want to only put trivial function calls in there (not even printf or ESP_LOGI), but you use a *_from_isr() FreeRTOS call to wake up something else.