This timer is weird, where do I go wrong? I also attached 2 pictures with the logic analyzer on the output pin.
Thanks in advance!
Code: Select all
static void periodic_timer_callback(void *arg) {
if (toggle2 == 0) {
toggle2 = 1;
} else {
toggle2 = 0;
}
gpio_set_level(GPIO_OUTPUT_IO_2, toggle2);
}
Code: Select all
void InitTimer() {
const esp_timer_create_args_t periodic_timer_args = { .callback =
&periodic_timer_callback,
// name is optional, but may help identify the timer when debugging
.name = "periodic" };
ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer));
// The timer has been created but is not running yet
// Start the timers
ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, 52));
}