Square Wave Generation on Portenta with Tone()

Dear all,

I've been trying to generate a square wave using the tone() function on the Portenta using the Breakout Board. In particular, I am using GPIO pin 5, which only works if I use the alternative pin name of PG_3 as pointed out by @jerteach on Github back in March.

void setup() {
  pinMode(PG_3, OUTPUT); //set pulse pin
  pinMode(PG_10, OUTPUT); //reset pulse pin


void loop() {

  tone(PG_3, 1000); //square wave generated on GPIO pin 5 with frequency 1 kHz; 50% duty cycle

The code compiles and uploads successfully, but all I get are four short red LED blinks followed by four long LED blinks. I take it that tone() is not supported by the Portenta?

All the best,

I'm not certain what your issue is, but the mbed Arduino core which is used by the Portenta H7 certainly contains tone().



Now you can use this new library to generate Square Wave.

For example, this TimerInterruptTest creates a square wave at pin D5 of Portenta_H7