1.. zephyr:code-sample:: alarm
2   :name: Counter Alarm
3   :relevant-api: counter_interface
4
5   Implement an alarm application using the counter API.
6
7Overview
8********
9This sample provides an example of alarm application using :ref:`counter API <counter_api>`.
10It sets an alarm with an initial delay of 2 seconds. At each alarm
11expiry, a new alarm is configured with a delay multiplied by 2.
12
13.. note::
14   In case of 1Hz frequency (RTC for example), precision is 1 second.
15   Therefore, the sample output may differ in 1 second
16
17Requirements
18************
19
20This sample requires the support of a timer IP compatible with alarm setting.
21
22References
23**********
24
25- :zephyr:board:`disco_l475_iot1`
26
27Building and Running
28********************
29
30 .. zephyr-app-commands::
31    :zephyr-app: samples/drivers/counter/alarm
32    :host-os: unix
33    :board: disco_l475_iot1
34    :goals: run
35    :compact:
36
37Sample Output
38=============
39
40 .. code-block:: console
41
42    Counter alarm sample
43
44    Set alarm in 2 sec
45    !!! Alarm !!!
46    Now: 2
47    Set alarm in 4 sec
48    !!! Alarm !!!
49    Now: 6
50    Set alarm in 8 sec
51    !!! Alarm !!!
52    Now: 14
53    Set alarm in 16 sec
54    !!! Alarm !!!
55    Now: 30
56
57    <repeats endlessly>
58