Re: Using counter (with RTC) on #nrf52832
Chruściński, Krzysztof
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):
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);
}
|
|||||||||||||||||||||
|