Re: Using counter (with RTC) on #nrf52832


Chruściński, Krzysztof
 

Hi Diogo,

 

As written before “Note that for other drivers enabling instances happens in Device Tree. Counter will be aligned to that at some point.”.

We are going towards instances being enabled in DT and counter is not yet there.

 

Regards,

Krzysztof

 

From: Diogo Correia <diogo.correia@...>
Sent: Friday, August 7, 2020 11:08 AM
To: Chruściński, Krzysztof <Krzysztof.Chruscinski@...>; users@...
Subject: Re: [Zephyr-users] Using counter (with RTC) on #nRF52832

 

Hi Krzysztof,

I thought that the use of one of the counters would be considered due to its presence in the device-tree.
So from what I understood, every instance from the device-tree must be enabled, either on .conf or Kconfig files? I'm asking this, because i've used a sensor (with TWI), did not enabled the port on the config file, just created added it into the .orverlay file, and it worked.

 

Kind regards,

Diogo

 

Diogo Correia 

Junior Researcher | Fraunhofer Portugal AICOS
t. +351 220430300  w. www.fraunhofer.pt

 


De: Chruściński, Krzysztof <Krzysztof.Chruscinski@...>
Enviado: 7 de agosto de 2020 06:49:32
Para: Diogo Correia; users@...
Assunto: RE: [Zephyr-users] Using counter (with RTC) on #nRF52832

 

Hi Diogo,

 

CMake is complaining because even though COUNTER driver is enabled there is no COUNTER instance enabled. In the example there is a Kconfig (samples/drivers/counter/alarm/Kconfig) which enabled COUNTER_RTC0 for Nordic platform and you need to do the same.

 

Note that for other drivers enabling instances happens in Device Tree. Counter will be aligned to that at some point.

 

Regards,

Krzysztof

 

From: users@... <users@...> On Behalf Of Diogo Correia via lists.zephyrproject.org
Sent: Thursday, August 6, 2020 3:23 PM
To: users@...
Subject: [Zephyr-users] Using counter (with RTC) on #nRF52832

 

Hi there,

 

I've started using Zephyr OS last week, so is better to advise that there might be a tiny chance of this question being dumb. I'm trying to use the Nordic's nRF52832 RTC clock, so wrote a small piece of software (based on the samples/counter/alarm/ example). However, when trying to compile I receive the following error:

 

CMake Error at /home/diogo.correia/zephyrproject/zephyr/cmake/extensions.cmake:372 (add_library):
  No SOURCES given to target: drivers__counter
Call Stack (most recent call first):
  /home/diogo.correia/zephyrproject/zephyr/cmake/extensions.cmake:349 (zephyr_library_named)
  /home/diogo.correia/zephyrproject/zephyr/drivers/counter/CMakeLists.txt:3 (zephyr_library)


-- Build files have been written to: /home/diogo.correia/zephyrproject/zephyrLAB/build
FAILED: build.ninja
/usr/local/bin/cmake -S/home/diogo.correia/zephyrproject/zephyrLAB -B/home/diogo.correia/zephyrproject/zephyrLAB/build
ninja: error: rebuilding 'build.ninja': subcommand failed
FATAL ERROR: command exited with status 1: /usr/local/bin/cmake --build /home/diogo.correia/zephyrproject/zephyrLAB/build

 

 

My .conf file:

 

#Nordic nRF52 RTT LOGGER

 

CONFIG_USE_SEGGER_RTT=y

 

CONFIG_RTT_CONSOLE=y

 

CONFIG_UART_CONSOLE=n

 

 

 

#Counter

 

CONFIG_COUNTER=y

 

 

 

My .c file:

 

#include

<zephyr.h>

 

#include

<sys/printk.h>

 

#include

<device.h>

 

#include

<drivers/counter.h>

 

 

 

#if

defined(CONFIG_COUNTER_RTC0)

 

#define TIMER

DT_LABEL(DT_NODELABEL(rtc0))

 

#elif

defined(CONFIG_COUNTER_RTC1)

 

#define TIMER

DT_LABEL(DT_NODELABEL(rtc1))

 

#elif

defined(CONFIG_COUNTER_RTC2)

 

#define TIMER

DT_LABEL(DT_NODELABEL(rtc2))

 

#endif

 

 

 

 

 

struct device *counter;

 

 

 

struct counter_alarm_cfg alarm_config;

 

 

 

void

init();

 

void

counter_callback(struct device *counter_dev,

u8_t

chan_id,

u32_t ticks,

void *user_data);

 

 

 

 

 

 

 

 

 

void

main(void)

 

{

 

init();

 

while(1) {

 

k_sleep(K_FOREVER);

 

}

 

 

}

 

 

 

 

 

 

 

 

void

init(){

 

// Counter

 

counter = device_get_binding(TIMER);

 

if (counter ==

NULL){

 

printk("ERROR: %s not found.\n",

TIMER);

 

return;

 

}

 

counter_start(counter);

 

alarm_config.flags =

0;

 

alarm_config.ticks =

counter_us_to_ticks(counter,

1000000);

 

alarm_config.callback = counter_callback;

 

counter_set_channel_alarm(counter,

0, &alarm_config);

 

}

 

 

 

 

 

 

 

 

Join users@lists.zephyrproject.org to automatically receive all group messages.