Portenta (M7) timer interrupt example

Hi,
Is there any periodic timer interrupt example for Portenta? I tried many libraries claiming it is working but it doesn't compile.

Thanks

I've used the mbed os tickers with some sucess.

#include "mbed.h"

using namespace mbed;

Ticker t;
uint8_t t0 = 0;

void setVar() {
  //digitalWrite(LEDB,LOW);
  if (t0 == 1) {
    t0 = 0;
  }
  else {
    t0 = 1;
  }
}

void setup() {
  Serial.begin(115200);
  t.attach(&setVar, 0.2); // .attach(&function,seconds) or .attach_us(&function, microseconds)
}

void loop() {
  if (t0 == 1) {
    digitalWrite(LEDB, LOW);
  }
  if (t0 == 0) {
    digitalWrite(LEDB, HIGH);
  }
  Serial.println(t0);
  delay(100);
}

Hope this helps.

Thank you for your response,
This is a soft timer which I was not looking for. I was looking for more like a hardware timer like Timer1 in Arduino.

I was able to find a good library for making concurrent threading that was running on top of mbed OS and made an example for reference :

/**
* Blinking example using threaded timer 
* By  : Waleed El-Badry
* Date: 20/02/2021
**/

// Threaded timer library: https://github.com/Aduen/ThreadedTimer
#include <threadedtimer.h>


// Thread Object
ThreadedTimer t1;

// Task ID
int taskBlink;

// Blue LED on RGB
int led = LEDB;

// Variable to save last LED status
volatile bool led_status = true;


// Blinking routine
void blinking()
{
  digitalWrite(led, led_status);
  led_status = !led_status;
}

void setup() 
{

  // Set LED GPIO as output
  pinMode(led, OUTPUT);

  // Create blinking task to enter every blinking() routine every 500 ms
  taskBlink = t1.every(500, blinking);
  
}

void loop() 
{
  delay(2000); //main loop delay does not affect the running Timers
}

Hi wbadry, Do you know if the Thread library still works? I tried to use it to perform a timer interrupt but it gave me an error which is the following "exit status 1
Error compiling for Arduino Portenta H7 (M7 core) board. "

Thanks.

Yes, it is broken now. I am looking for an alternative

Thank you for your response,
I've also been looking for an alternative, but so far nothing has worked.