Mentorship for developing RP2040 MBED os

Hi,

I am unsure if this is correct place for it. But I am properly stuck. I bought the RP2040 arduino nano so that I could build a voice recognition unit. That would play audio output when detected. Audio via I2S to a DAC from an sd card reader using WAV.

I have in seperate cases got both systems working. So voice recognition on the mbed os. And sd card and playback via arduino-pico core. Ive searched high and low for simple I2S libraries for mbed os.

I found this example, I tried to then put this into Arduino IDE. downloaded libs from github and imported zips. did not compile as it had an issue with the Ticker function. And then I just imported ticker from libraries within IDE. And still does not like the definition of ticker. I am really confused. Platform IDE does not support mbed environment.

this is error I am getting: error: 'Ticker' does not name a type
Ticker timer1(printMessage, 0, 1);
^~~~~~

#include <Ticker.h>

void printMessage();
void printCounter();
void printCountdown();
void blink();
void printCountUS();

bool ledState;
int counterUS;

Ticker timer1(printMessage, 0, 1);
Ticker timer2(printCounter, 1000, 0, MILLIS);
Ticker timer3(printCountdown, 1000, 5);
Ticker timer4(blink, 500);
Ticker timer5(printCountUS, 100, 0, MICROS_MICROS);


void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);
  delay(2000);
  timer1.start();
  timer2.start();
  timer3.start();
  timer4.start();
  timer5.start();
  }

void loop() {
  timer1.update();
  timer2.update();
  timer3.update();
  timer4.update();
  timer5.update();
  if (timer4.counter() == 20) timer4.interval(200);
  if (timer4.counter() == 80) timer4.interval(1000);
  }

void printCounter() {
  Serial.print("Counter ");
  Serial.println(timer2.counter());
  }

void printCountdown() {
  Serial.print("Countdowm ");
  Serial.println(5 - timer3.counter());
  }

void printMessage() {
  Serial.println("Hello!");
  }

void blink() {
  digitalWrite(LED_BUILTIN, ledState);
  ledState = !ledState;
  }

void printCountUS() {
  counterUS++;  
  if (counterUS == 10000) {
    Serial.println("10000 * 100us");
    counterUS = 0;
    }
  }

Hi @embeddedexplore. From the "Ticker" library's readme:

https://github.com/sstaub/Ticker#readme

Advice: for use with ESP boards and mbed based Arduino boards like Arduino Nano RP2040 Connect and Raspberry Pi Pico (using the official Arduino core) the TickTwo library GitHub - sstaub/TickTwo: Ticker library for ESP and mbed based Arduino boards is recommanded avoiding name conflicts.

So use the Arduino IDE Library Manager to install the "TickTwo" library. After that, select File > Examples > TickTwo > Ticker from the Arduino IDE menus. This sketch is the equivalent to the one you shared here, except with the minor adjustments for use with the TickTwo library.


The reason you weren't able to use the Ticker library library with the Nano RP2040 Connect board, and the reason why the author of that library created the alternative TickTwo variant, is because Mbed OS contains a header file named Ticker.h:

https://os.mbed.com/docs/mbed-os/latest/mbed-os-api-doxy/_ticker_8h_source.html

That header was #included instead of the header from the Ticker Arduino library.

1 Like