`Too many arguments to function hw_timer_t

Hi, new to this, but running and a MH ET Live ESP32 Mini Kit Board and got this error in compiling. It is pretty self-explanatory, the function will not take my variables, but does anyone know why it is being thrown and more importantly, how to fix
it?
libraries\RadioHead_v1.121\RH_ASK.cpp:528:23: error: too many arguments to function 'hw_timer_t* timerBegin(uint32_t)' 528 | timer = timerBegin(0, 80, true); // Alarm value will be in in us
| ^~~

The entire log is here:
c:\Users\mccaya\Documents\Arduino\libraries\RadioHead_v1.121\RH_ASK.cpp: In member function 'void RH_ASK::timerSetup()':
c:\Users\mccaya\Documents\Arduino\libraries\RadioHead_v1.121\RH_ASK.cpp:528:23: error: too many arguments to function 'hw_timer_t* timerBegin(uint32_t)'
528 | timer = timerBegin(0, 80, true); // Alarm value will be in in us
| ^~~
In file included from C:\Users\mccaya\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\cores\esp32/esp32-hal.h:98,
from C:\Users\mccaya\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\cores\esp32/Arduino.h:45,
from c:\Users\mccaya\Documents\Arduino\libraries\RadioHead_v1.121/RadioHead.h:1544,
from c:\Users\mccaya\Documents\Arduino\libraries\RadioHead_v1.121/RHGenericDriver.h:9,
from c:\Users\mccaya\Documents\Arduino\libraries\RadioHead_v1.121/RH_ASK.h:9,
from c:\Users\mccaya\Documents\Arduino\libraries\RadioHead_v1.121\RH_ASK.cpp:6:
C:\Users\mccaya\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\cores\esp32/esp32-hal-timer.h:35:13: note: declared here
35 | hw_timer_t timerBegin(uint32_t frequency);
| ^~~~~~~~~~
c:\Users\mccaya\Documents\Arduino\libraries\RadioHead_v1.121\RH_ASK.cpp:529:25: error: too many arguments to function 'void timerAttachInterrupt(hw_timer_t
, void (*)())'
529 | timerAttachInterrupt(timer, &esp32_timer_interrupt_handler, true);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\mccaya\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\cores\esp32/esp32-hal-timer.h:50:6: note: declared here
50 | void timerAttachInterrupt(hw_timer_t *timer, void (*userFunc)(void));
| ^~~~~~~~~~~~~~~~~~~~
c:\Users\mccaya\Documents\Arduino\libraries\RadioHead_v1.121\RH_ASK.cpp:530:5: error: 'timerAlarmWrite' was not declared in this scope; did you mean 'timerWrite'?
530 | timerAlarmWrite(timer, 1000000 / _speed / 8, true);
| ^~~~~~~~~~~~~~~
| timerWrite
c:\Users\mccaya\Documents\Arduino\libraries\RadioHead_v1.121\RH_ASK.cpp:531:5: error: 'timerAlarmEnable' was not declared in this scope; did you mean 'timerAlarm'?
531 | timerAlarmEnable(timer);
| ^~~~~~~~~~~~~~~~
| timerAlarm
exit status 1

Compilation error: exit status 1

Hi @wxman23 ,

Welcome to the forum..
check the documentation for the lib RadioHead..

looks like it only support up to 3.0.2 of the esp32 core you are using 3.2.0

try downgrading your esp32 core..

good luck.. ~q

1 Like

Check out the pinned post re 'How to get the most from the forum'. After you do that, have a look at the RH_ASK.h file to see what the arguments should be.
Meanwhile, edit your post and add code tags.

it looks like you are attempting to build code using ESP32 core 3.x which was implemented for ESP32 core 2.x

have a look at the ESP32 core V3.x Arduino-ESP32 Timer API

also worth looking at is Migration from ESP32 core 2.x to 3.x

Thanks all. I had to walk back to 2.0.17 but it compiles now.

the alternative is to update the code to use ESP32 core V3.x
e.g. generating a 1Hz square wave

// ESP32 timer inteerrupts -   1Hz square wave print period counter

// updated to use ESP32 core V3.0 - changes indicated by <<<

#define pin 19

hw_timer_t *timer = NULL;

// timer ISR invert pin level
volatile int counter = 0;
void ARDUINO_ISR_ATTR onTimer() {
  static uint32_t level = 0;
  counter++;
  // digitalWrite(pin, !digitalRead(pin));
  gpio_set_level((gpio_num_t)pin, level);  //!gpio_get_level((gpio_num_t)pin));
  level = !level;
}

void setup() {
  Serial.begin(115200);
  pinMode(pin, OUTPUT);
  timer = timerBegin(100000);             // <<< Set timer frequency Mhz
  timerAttachInterrupt(timer, &onTimer);  // <<< Attach onTimer function to our timer.
  // Set alarm to call onTimer function(value in microseconds).
  // Repeat the alarm (third parameter) with unlimited count = 0 (fourth parameter).
  timerAlarm(timer, 50000, true, 0);       // <<<
}

void loop() {
  // display counter every second
  static long timer1 = millis();
  if (millis() - timer1 > 1000) {
    timer1 = millis();
    Serial.println(counter);
    counter = 0;
  }
}

if the problem is solved click the Solution button at the bottom of the reply that answered the question - this helps others with a similar question