Using counter (with RTC) on #nrf52832


Diogo Correia <diogo.correia@...>
 

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);
}



Diogo Correia
Junior Researcher
 
 
Fraunhofer Portugal Research Center for
Assistive Information and Communication Solutions
Rua Alfredo Allen 455/461
4200-135 Porto, Portugal
follow us on facebook youtube linkedin twitter
t. +351 220430300
f. +351 226005029
e. diogo.correia@...
w. www.fraunhofer.pt

Fraunhofer Portugal Challenge 2018

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