invalid conversion from 'void (*)()' to 'pico_timer_callback' {aka 'bool (*)(repeating_timer*)'} #2

Closed
opened 2022-04-15 21:45:47 +03:00 by janczeresnia · 1 comment
janczeresnia commented 2022-04-15 21:45:47 +03:00 (Migrated from github.com)

Hi
I get an error compiling an example from your git website on Raspberry Pico Core 1.13.1 in Arduino
I'm trying to use only Hardware Timer directly:

#include <RPi_Pico_TimerInterrupt.h>

#define TIMER_FREQ_HZ 8000.000
#define TIMER_INTERVAL_US 125

RPI_PICO_Timer ITimer1(1);

volatile uint32_t lastIsrMicros = 0;
volatile uint32_t deltaIsrMicros;

TimerHandler:

void TimerHandler() {
  deltaIsrMicros = micros() - lastIsrMicros;
  lastIsrMicros = micros();
}
  • 1.2 Set Hardware Timer Interval and attach Timer Interrupt Handler function directly OR
  if (ITimer1.attachInterruptInterval(TIMER_INTERVAL_US, TimerHandler)) { <---- Error
    Serial.println("Starting ITimer OK, millis() = " + String(millis()));
  } else {
    Serial.println("Can't set ITimer. Select another freq. or timer");
  }

Error : invalid conversion from 'void ()()' to 'pico_timer_callback' {aka 'bool ()(repeating_timer*)'} [-fpermissive]

  • 1.3 Set Hardware Timer Frequency and attach Timer Interrupt Handler function.
if (ITimer1.setFrequency(TIMER_FREQ_HZ, TimerHandler)) { <---- Error
    Serial.println("Starting ITimer OK, millis() = " + String(millis()));
  } else {
    Serial.println("Can't set ITimer. Select another freq. or timer");
  }

Error : invalid conversion from 'void ()()' to 'pico_timer_callback' {aka 'bool ()(repeating_timer*)'} [-fpermissive]

And in loop

void loop() {
    Serial.println("delta: " + String(deltaIsrMicros));
    delay(1000);
}

I have fixed this error.
Change TimerHandler to:

bool TimerHandler(struct repeating_timer *t) {
  deltaIsrMicros = micros() - lastIsrMicros;
  lastIsrMicros = micros();
  return true;
}
Hi I get an error compiling an example from your git website on Raspberry Pico Core 1.13.1 in Arduino I'm trying to use only Hardware Timer directly: ``` #include <RPi_Pico_TimerInterrupt.h> #define TIMER_FREQ_HZ 8000.000 #define TIMER_INTERVAL_US 125 RPI_PICO_Timer ITimer1(1); volatile uint32_t lastIsrMicros = 0; volatile uint32_t deltaIsrMicros; ``` TimerHandler: ``` void TimerHandler() { deltaIsrMicros = micros() - lastIsrMicros; lastIsrMicros = micros(); } ``` - 1.2 Set Hardware Timer Interval and attach Timer Interrupt Handler function directly OR ``` if (ITimer1.attachInterruptInterval(TIMER_INTERVAL_US, TimerHandler)) { <---- Error Serial.println("Starting ITimer OK, millis() = " + String(millis())); } else { Serial.println("Can't set ITimer. Select another freq. or timer"); } ``` Error : invalid conversion from 'void (*)()' to 'pico_timer_callback' {aka 'bool (*)(repeating_timer*)'} [-fpermissive] - 1.3 Set Hardware Timer Frequency and attach Timer Interrupt Handler function. ``` if (ITimer1.setFrequency(TIMER_FREQ_HZ, TimerHandler)) { <---- Error Serial.println("Starting ITimer OK, millis() = " + String(millis())); } else { Serial.println("Can't set ITimer. Select another freq. or timer"); } ``` Error : invalid conversion from 'void (*)()' to 'pico_timer_callback' {aka 'bool (*)(repeating_timer*)'} [-fpermissive] And in loop ``` void loop() { Serial.println("delta: " + String(deltaIsrMicros)); delay(1000); } ``` I have fixed this error. Change TimerHandler to: ``` bool TimerHandler(struct repeating_timer *t) { deltaIsrMicros = micros() - lastIsrMicros; lastIsrMicros = micros(); return true; } ```
khoih-prog commented 2022-04-15 22:18:28 +03:00 (Migrated from github.com)

Great that you can solve the problem by yourself.
It's always better to recheck the working examples and compare to see what we're doing not correctly.

Great that you can solve the problem by yourself. It's always better to recheck the working examples and compare to see what we're doing not correctly.
Sign in to join this conversation.