How to generate interruptions with a 100us timer?

walter.paz
Posts: 4
Joined: Wed Jan 12, 2022 7:56 am

How to generate interruptions with a 100us timer?

Postby walter.paz » Wed Apr 03, 2024 3:38 pm

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.

ESP_Sprite
Posts: 9708
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Thu Apr 04, 2024 2:44 am

You'd use the high precision timer, or if getting the interrupts in time is really important, one of the hardware timers.

walter.paz
Posts: 4
Joined: Wed Jan 12, 2022 7:56 am

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

Postby walter.paz » Fri Apr 05, 2024 5:07 pm

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?

ESP_Sprite
Posts: 9708
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Sat Apr 06, 2024 5:38 am

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.

Who is online

Users browsing this forum: Bing [Bot], YaCy [Bot] and 66 guests