TACHOMETER Timer AVR to ESP 32 timer ERROR

Hola estoy implementando un tacómetro en un esp32 el problema es que no he logrado hacer uso del ejemplo con interrupciones del siguiente hilo:

ESP32TimerInterrupt - Referencia de Arduino

En fin lo que quiero es un tacómetro capas de medir exactamente y no solo en múltiplos de 60 como he visto en muchos ejemplos, si alguien sabe como solucionar el error o sabe de alguna otra manera de hacerlo me seria de ayuda, en fin este es el error que tengo con el ejemplo del tacómetro.

CODIGO

#if !defined(ESP32)
  #error This code is intended to run on the ESP32 platform! Please check your Tools->Board setting.
#elif ( defined(ARDUINO_ESP32S3_DEV) || defined(ARDUINO_ESP32_S3_BOX) || defined(ARDUINO_TINYS3) || \
        defined(ARDUINO_PROS3) || defined(ARDUINO_FEATHERS3) )
  #error ESP32_S3 is not supported yet
#endif

// These define's must be placed at the beginning before #include "TimerInterrupt_Generic.h"
// _TIMERINTERRUPT_LOGLEVEL_ from 0 to 4
#define _TIMERINTERRUPT_LOGLEVEL_     0

// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include <ESP32TimerInterrupt.h>

// Don't use PIN_D1 in core v2.0.0 and v2.0.1. Check https://github.com/espressif/arduino-esp32/issues/5868
#define PIN_D2              2         // Pin D2 mapped to pin GPIO2/ADC12/TOUCH2/LED_BUILTIN of ESP32
#define PIN_D3              3         // Pin D3 mapped to pin GPIO3/RX0 of ESP32
#define PIN_D4              4         // Pin D4 mapped to pin GPIO4/ADC10/TOUCH0 of ESP32

unsigned int SWPin = PIN_D4;

#define TIMER0_INTERVAL_MS        1
#define DEBOUNCING_INTERVAL_MS    80

#define LOCAL_DEBUG               1

// Init ESP32 timer 0
ESP32Timer ITimer0(0);

volatile unsigned long rotationTime = 0;

// Not using float => using RPM = 100 * real RPM
float RPM       = 0;
float avgRPM    = 0;
//uint32_t RPM       = 0;
//uint32_t avgRPM    = 0;

volatile int debounceCounter;

// With core v2.0.0+, you can't use Serial.print/println in ISR or crash.
// and you can't use float calculation inside ISR
// Only OK in core v1.0.6-
bool IRAM_ATTR TimerHandler0(void * timerNo)
{ 
  if ( !digitalRead(SWPin) && (debounceCounter >= DEBOUNCING_INTERVAL_MS / TIMER0_INTERVAL_MS ) )
  {
    //min time between pulses has passed
    // Using float calculation / vars in core v2.0.0 and core v2.0.1 will cause crash
    // Not using float => using RPM = 100 * real RPM
    RPM = ( 6000000 / ( rotationTime * TIMER0_INTERVAL_MS ) );

    avgRPM = ( 2 * avgRPM + RPM) / 3;

    rotationTime = 0;
    debounceCounter = 0;
  }
  else
  {
    debounceCounter++;
  }

  //if (rotationTime >= 5000)
  if (rotationTime >= 1000)
  {
    // If idle, set RPM to 0, don't increase rotationTime
    RPM = 0;

    avgRPM = ( avgRPM + 3 * RPM) / 4;
     
    rotationTime = 0;
  }
  else
  {
    rotationTime++;
  }

  return true;
}

void setup()
{
  pinMode(SWPin, INPUT_PULLUP);
  
  Serial.begin(115200);
  while (!Serial);

  delay(200);
  
  Serial.print(F("\nStarting RPM_Measure on ")); Serial.println(ARDUINO_BOARD);
  Serial.println(ESP32_TIMER_INTERRUPT_VERSION);
  Serial.print(F("CPU Frequency = ")); Serial.print(F_CPU / 1000000); Serial.println(F(" MHz"));

  // Using ESP32  => 80 / 160 / 240MHz CPU clock ,
  // For 64-bit timer counter
  // For 16-bit timer prescaler up to 1024

  // Interval in microsecs
  if (ITimer0.attachInterruptInterval(TIMER0_INTERVAL_MS * 1000, TimerHandler0))
  {
    Serial.print(F("Starting  ITimer0 OK, millis() = ")); Serial.println(millis());
  }
  else
    Serial.println(F("Can't set ITimer0. Select another freq. or timer"));

  Serial.flush();   
}

void loop()
{
  if (avgRPM > 0)
  {
    Serial.print(F("RPM  = ")); Serial.print((float) RPM / 100.f); Serial.print(F(", avgRPM  = ")); Serial.println((float) avgRPM / 100.f);
  }

  delay(1000);
}

ERROR

Arduino:1.8.19 (Windows 10), Tarjeta:"ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None"

In file included from C:\Users\IDROID\Documents\Arduino\libraries\ESP32TimerInterrupt\src/ESP32TimerInterrupt.h:58:0,

                 from C:\Users\IDROID\Desktop\RPM_INTERRUP\RPM_INTERRUP.ino:13:

C:\Users\IDROID\Documents\Arduino\libraries\ESP32TimerInterrupt\src/ESP32TimerInterrupt.hpp: In member function 'bool ESP32TimerInterrupt::setFrequency(const float&, bool (* const&)(void*))':

C:\Users\IDROID\Documents\Arduino\libraries\ESP32TimerInterrupt\src/ESP32TimerInterrupt.hpp:355:100: error: 'timer_isr_callback_add' was not declared in this scope

         timer_isr_callback_add(_timerGroup, _timerIndex, _callback, (void *) (uint32_t) _timerNo, 0);

                                                                                                    ^

C:\Users\IDROID\Documents\Arduino\libraries\ESP32TimerInterrupt\src/ESP32TimerInterrupt.hpp: In member function 'void ESP32TimerInterrupt::detachInterrupt()':

C:\Users\IDROID\Documents\Arduino\libraries\ESP32TimerInterrupt\src/ESP32TimerInterrupt.hpp:397:66: error: 'TIMER_INTR_T0' was not declared in this scope

       timer_group_intr_disable(_timerGroup, (_timerIndex == 0) ? TIMER_INTR_T0 : TIMER_INTR_T1);

                                                                  ^

C:\Users\IDROID\Documents\Arduino\libraries\ESP32TimerInterrupt\src/ESP32TimerInterrupt.hpp:397:82: error: 'TIMER_INTR_T1' was not declared in this scope

       timer_group_intr_disable(_timerGroup, (_timerIndex == 0) ? TIMER_INTR_T0 : TIMER_INTR_T1);

                                                                                  ^

C:\Users\IDROID\Documents\Arduino\libraries\ESP32TimerInterrupt\src/ESP32TimerInterrupt.hpp: In member function 'void ESP32TimerInterrupt::disableTimer()':

C:\Users\IDROID\Documents\Arduino\libraries\ESP32TimerInterrupt\src/ESP32TimerInterrupt.hpp:406:66: error: 'TIMER_INTR_T0' was not declared in this scope

       timer_group_intr_disable(_timerGroup, (_timerIndex == 0) ? TIMER_INTR_T0 : TIMER_INTR_T1);

                                                                  ^

C:\Users\IDROID\Documents\Arduino\libraries\ESP32TimerInterrupt\src/ESP32TimerInterrupt.hpp:406:82: error: 'TIMER_INTR_T1' was not declared in this scope

       timer_group_intr_disable(_timerGroup, (_timerIndex == 0) ? TIMER_INTR_T0 : TIMER_INTR_T1);

                                                                                  ^

C:\Users\IDROID\Documents\Arduino\libraries\ESP32TimerInterrupt\src/ESP32TimerInterrupt.hpp: In member function 'void ESP32TimerInterrupt::reattachInterrupt()':

C:\Users\IDROID\Documents\Arduino\libraries\ESP32TimerInterrupt\src/ESP32TimerInterrupt.hpp:416:65: error: 'TIMER_INTR_T0' was not declared in this scope

       timer_group_intr_enable(_timerGroup, (_timerIndex == 0) ? TIMER_INTR_T0 : TIMER_INTR_T1);

                                                                 ^

C:\Users\IDROID\Documents\Arduino\libraries\ESP32TimerInterrupt\src/ESP32TimerInterrupt.hpp:416:81: error: 'TIMER_INTR_T1' was not declared in this scope

       timer_group_intr_enable(_timerGroup, (_timerIndex == 0) ? TIMER_INTR_T0 : TIMER_INTR_T1);

                                                                                 ^

C:\Users\IDROID\Documents\Arduino\libraries\ESP32TimerInterrupt\src/ESP32TimerInterrupt.hpp: In member function 'void ESP32TimerInterrupt::enableTimer()':

C:\Users\IDROID\Documents\Arduino\libraries\ESP32TimerInterrupt\src/ESP32TimerInterrupt.hpp:426:65: error: 'TIMER_INTR_T0' was not declared in this scope

       timer_group_intr_enable(_timerGroup, (_timerIndex == 0) ? TIMER_INTR_T0 : TIMER_INTR_T1);

                                                                 ^

C:\Users\IDROID\Documents\Arduino\libraries\ESP32TimerInterrupt\src/ESP32TimerInterrupt.hpp:426:81: error: 'TIMER_INTR_T1' was not declared in this scope

       timer_group_intr_enable(_timerGroup, (_timerIndex == 0) ? TIMER_INTR_T0 : TIMER_INTR_T1);

                                                                                 ^

exit status 1

Error compilando para la tarjeta ESP32 Dev Module.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.