This is the documentation for the latest (main) development branch of Zephyr. If you are looking for the documentation of previous releases, use the drop-down menu on the left and select the desired version.

Counter Alarm Sample

Overview

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.

Note

In case of 1Hz frequency (RTC for example), precision is 1 second. Therefore, the sample output may differ in 1 second

Requirements

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

Building and Running

west build -b disco_l475_iot1 samples/drivers/counter/alarm
west build -t 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>