Skip to content
Browse files

samples: Counter alarm should display seconds, not ticks

The message talks about seconds but displays ticks. Adjusting the
parameter to convert ticks to seconds then. But also adding the ticks
since it is a valuable information when testing counter devices.

Fixing small style issue (parameter indentation) as well.

Signed-off-by: Tomasz Bursztyka <>
  • Loading branch information...
tbursztyka authored and carlescufi committed Aug 2, 2019
1 parent b837252 commit 08a93d276b5040f1f3fc522580e48acccec85ce0
Showing with 10 additions and 3 deletions.
  1. +10 −3 samples/drivers/counter/alarm/src/main.c
@@ -16,7 +16,8 @@
struct counter_alarm_cfg alarm_cfg;

static void test_counter_interrupt_fn(struct device *counter_dev,
u8_t chan_id, u32_t ticks, void *user_data)
u8_t chan_id, u32_t ticks,
void *user_data)
u32_t now_ticks = counter_read(counter_dev);
u64_t now_usec = counter_ticks_to_us(counter_dev, now_ticks);
@@ -29,7 +30,10 @@ static void test_counter_interrupt_fn(struct device *counter_dev,
/* Set a new alarm with a double length duration */
config->ticks = config->ticks * 2U;

printk("Set alarm in %u sec\n", config->ticks);
printk("Set alarm in %u sec (%u ticks)\n",
config->ticks) / USEC_PER_SEC),
counter_set_channel_alarm(counter_dev, ALARM_CHANNEL_ID, user_data);

@@ -54,7 +58,10 @@ void main(void)

err = counter_set_channel_alarm(counter_dev, ALARM_CHANNEL_ID,
printk("Set alarm in %d sec\n", alarm_cfg.ticks);
printk("Set alarm in %u sec (%u ticks)\n",
alarm_cfg.ticks) / USEC_PER_SEC),

if (-EINVAL == err) {
printk("Alarm settings invalid\n");

0 comments on commit 08a93d2

Please sign in to comment.
You can’t perform that action at this time.