How to use the timer interrupt on XIAO BLE

I can run the example code on XIAO with ‘TimerTCC0’ to interrupt ,but how can i do that with XIAO BLE?

I am also very interested to know!
I currently use XIAO BLE Sense, and timer interrupt functionality is quite essential. I have seen examples for classic Arduino kits (such as Uno), as well as XIAO, but not XIAO BLE /(Sense)

Please don’t let this thread die unanswered :grinning:

Here are my steps to illustrate timer interrupt functionality for the XIAO BLE and XIAO BLE Sense boards:

1. Use the Boards Manager to install the “Seeed nRF52 mbed-enabled Boards” package latest version: 2.7.2 (First attachment below)

2. Select the “Seeed XIAO BLE Sense - nRF52840” board from the “Seeed nRF52 mbed-enabled Boards” group (Second attachment)

3. Use the Libraries Manager to install the “NRF52_MBED_TimerInterrupt” library (Third Attachment)

4. Open the “TimerInterruptTest” sketch in the Examples folder of that library

5. The LED definitions for this example are for the Nano 33 BLE board, and they have to be changed for the XIAO BLE and XIAO BLE Sense boards.
Change this

#ifndef LED_BLUE_PIN
  #define LED_BLUE_PIN            D7
#endif
#ifndef LED_RED_PIN
  #define LED_RED_PIN             D8
#endif

to this:

// For the XIAO BLE  and XIAO BLE Sense boards, pins_arduino.h
// defines LEDR, LEDG, and LEDB
#define LED_BLUE_PIN LEDB
#define LED_RED_PIN  LEDR /* Same as LED_BUILTIN */

6. Compile and upload the sketch.

For me, things work as expected: The Red LED (LED_BUILTIN) blinks at its specified cadence, and the Blue LED blinks at its cadence

Output on the Serial Monitor is the fourth attachment below, and finally (I promise) my sketch is the last one.

Regards,

Dave

TimerInterruptTest_Output

XIAO_BLE_TimerInterruptTest.zip (2.7 KB)

2 Likes

Hi Dave,

Apologies for my late reply to this thread. Thank you so so so much for this detailed explanation, I can confirm that all of these steps worked as expected/described. Indeed I have gotten the timer interrupt to work correctly! :slight_smile:

Some other threads have discussed how to use XIAO BLE Sense power saving; between the system OFF and system ON sleeping modes, it seems that system-on-sleeping-mode with timer-interrupt to wake the system up, is a viable option that can save quite a bit of power.

I have managed to reduce the power consumption down to 1mA (in either system-on, or system-off sleeping), so this timer interrupt was essential to wake the hardware up periodically.

I might write a separate post on some power-saving techniques some time, since there are few posts about it on this forum.

Thank you so much!!! :blush: