zephyr/samples/drivers/counter/alarm
The Nguyen d4758f02b1 samples: counter: alarm: revert PR #90709
Due to the lack of the overlays for lots of platforms, bring up the
platform_allow again before the sample ifdef are refined

Signed-off-by: The Nguyen <the.nguyen.yf@renesas.com>
2025-06-17 16:13:03 +02:00
..
boards samples: drivers: counter: Add support alarm for lp_mspm0g3507 2025-06-10 10:25:10 -04:00
socs drivers: counter: fix counter node in esp32 timers 2025-06-02 22:36:03 -04:00
src samples: drivers: counter: Add support alarm for lp_mspm0g3507 2025-06-10 10:25:10 -04:00
sysbuild/vpr_launcher samples: drivers: counter: alarm: support nrf54h and nrf54l 2025-05-30 10:27:50 +02:00
CMakeLists.txt
Kconfig
prj.conf
README.rst
sample.yaml samples: counter: alarm: revert PR #90709 2025-06-17 16:13:03 +02:00

.. zephyr:code-sample:: alarm
   :name: Counter Alarm
   :relevant-api: counter_interface

   Implement an alarm application using the counter API.

Overview
********
This sample provides an example of alarm application using :ref:`counter API <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.

References
**********

- :zephyr:board:`disco_l475_iot1`

Building and Running
********************

 .. zephyr-app-commands::
    :zephyr-app: samples/drivers/counter/alarm
    :host-os: unix
    :board: disco_l475_iot1
    :goals: run
    :compact:

Sample Output
=============

 .. code-block:: console

    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>