Counter Alarm Sample


This sample provides an example of alarm application using counter API. It sets an alarm with an initial delay of 2 seconds. At each alarm expiry, a new alarm is configured with a delay multiplied by 2.


This sample requires the support of a timer IP compatible with alarm setting.

Building and Running

Using west:

west build -t run

Using CMake and ninja:

cmake -B build -GNinja -DBOARD=disco_l475_iot1 samples/counter/alarm
ninja -C build run

Sample Output

Counter alarm sample

Set alarm in 2 sec
!!! Alarm !!!
Now: 2
Set alarm in 4 sec
!!! Alarm !!!
Now: 6
Set alarm in 8 sec
!!! Alarm !!!
Now: 14
Set alarm in 16 sec
!!! Alarm !!!
Now: 30

<repeats endlessly>