Timer interrupts on XIAO

Does the XIAO support timer interrupts? If so, does anyone have a sample sketch for Arduino that demonstrates? I’m familiar with interrupts on the Uno, but my code fails to compile for the XIAO. Thanks.

You can try the API. I hope it meets your needs.
https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/

Thank you, that is most helpful.

That doesn’t look like a timer interrupt to me it looks like an interrupt on a pin.

Yeah, you’re right, that is all about interrupt pins

You’ve probably found something by now, so I guess this is for the benefit of anyone else looking

#include <Arduino.h>
#include <TimerTC3.h>

#define Transmission_Timer TimerTc3 

/****************
 * Forward declarations of functions
 *************************************************************/
void TRANSMISSION_ISR();
void transmit();

/****************
 * Evaluated to determine whether or not we need to send a message
 *************************************************************/
volatile bool TransmitNextMessage = false;

void setup()
{
  Serial.begin(115200);
  // allow time for serial start and port monitoring tool connection
  uint32_t timestamp = millis();
  while(millis() - timestamp < 2000)
    ;

  /****************
   * Initialize the timer and register the ISR function
   *************************************************************/
  Transmission_Timer.initialize();    // The default interval is 1000000 microseconds
  Transmission_Timer.attachInterrupt(TRANSMISSION_ISR);
}

unsigned long packetnum = 1; // packet counter, we increment per xmission
void loop()
{
  /****************
   * Disable the IRQ so that we can safely access the shared resource
   *************************************************************/
  __disable_irq();
  
  bool run = TransmitNextMessage;
  if(run)
    TransmitNextMessage = !TransmitNextMessage;

  /****************
   * Don't forget to reenable the IRQ
   *************************************************************/
  __enable_irq();

  if(run)
    transmit();
}

/****************
 * The ISR must return as quickly as possible
 *************************************************************/
void TRANSMISSION_ISR() { TransmitNextMessage = true; }

/****************
 * This function is called each time the Timer period elapses
 * but it happens as part of the main loop()
 * 
 * Remember that you should NEVER write to Serial
 * from within an ISR
 *************************************************************/
void transmit()
{
  Serial.printf("Hello World # %lu", packetnum++);
}