Closed
Description
Hi folks,
The hardware timer functions seem to have an issue in the IDF 4.2 branch. The following sketch correctly blinks the onboard LED in 1.0.5-rc6 - under 4.2, this sketch compiles but fails to fire the interrupt:
hw_timer_t * timer = NULL;
#define ledPin LED_BUILTIN
void onTimer() {
if (digitalRead(ledPin)) digitalWrite(ledPin, 0);
else digitalWrite(ledPin, 1);
}
void setup() {
pinMode(ledPin, OUTPUT);
timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &onTimer, true);
timerAlarmWrite(timer, 1000000, true);
timerAlarmEnable(timer);
}
void loop() {}
The native IDF functions do work in the 4.2 branch, as tested in this example:
#include "esp_timer.h"
#define ledPin LED_BUILTIN
void onTimer() {
if (digitalRead(ledPin)) digitalWrite(ledPin, 0);
else digitalWrite(ledPin, 1);
}
esp_timer_handle_t timer;
const esp_timer_create_args_t timerParameters = { .callback = reinterpret_cast<esp_timer_cb_t>(&onTimer) };
void setup() {
pinMode(ledPin, OUTPUT);
esp_timer_create(&timerParameters, &timer);
esp_timer_start_periodic(timer, 1000000);
}
void loop() {}
Is this currently the expected behavior? Per esp32-hal-timer.c
:
void timerAttachInterrupt(hw_timer_t *timer, void (*fn)(void), bool edge){
// EDGE DOES NOT WORK CURRENTLY
edge = false;
Thanks!
Environment: NodeMCU ESP-32S generic dev module, ESP32-S2 official dev board, macOS 11.1, Arduino IDE 1.8.13, core 1.0.5-rc6 and idf-release/v4.2.
Metadata
Metadata
Assignees
Labels
No labels