This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can I use two RTC in nRF5340?

Hello,

In nRF5340 I use one RTC and it works. Here is my code:

1) in prj.conf:

CONFIG_NRFX_RTC=y
CONFIG_NRFX_RTC0=y

2) in the code:

a) define:
nrfx_rtc_t sti_period_rtc_0 = NRFX_RTC_INSTANCE(0);

b):

IRQ_CONNECT(DT_IRQN(DT_NODELABEL(rtc0)),
DT_IRQ(DT_NODELABEL(rtc0), priority),
nrfx_isr, nrfx_rtc_0_irq_handler, 0);


nrfx_rtc_config_t period_rtc_0_config = NRFX_RTC_DEFAULT_CONFIG;

period_rtc_0_config.prescaler = 0;

nrfx_rtc_init( &sti_period_rtc_0, &period_rtc_0_config, period_rtc_0_handler );

==================================================

Now I want to use two RTC, so I add :

1) in prj.conf:

CONFIG_NRFX_RTC=y
CONFIG_NRFX_RTC0=y
CONFIG_NRFX_RTC1=y

2) in the code:


a) define:
nrfx_rtc_t sti_period_rtc_0 = NRFX_RTC_INSTANCE(0);

nrfx_rtc_t sti_period_rtc_1 = NRFX_RTC_INSTANCE(1);


b)

IRQ_CONNECT(DT_IRQN(DT_NODELABEL(rtc0)),
DT_IRQ(DT_NODELABEL(rtc0), priority),
nrfx_isr, nrfx_rtc_0_irq_handler, 0);


nrfx_rtc_config_t period_rtc_0_config = NRFX_RTC_DEFAULT_CONFIG;

period_rtc_0_config.prescaler = 0;

nrfx_rtc_init( &sti_period_rtc_0, &period_rtc_0_config, period_rtc_0_handler );


/////////////////////////////////////

IRQ_CONNECT(DT_IRQN(DT_NODELABEL(rtc1)),
DT_IRQ(DT_NODELABEL(rtc1), priority),
nrfx_isr, nrfx_rtc_1_irq_handler, 0);


nrfx_rtc_config_t period_rtc_1_config = NRFX_RTC_DEFAULT_CONFIG;

period_rtc_1_config.prescaler = 0;

nrfx_rtc_init( &sti_period_rtc_1, &period_rtc_1_config, period_rtc_1_handler );


///////////////////
then I run Project->run CMake in SEGGER EMbedded studio
and I got this error:

1> Combining ‘zephyr/isr_tables.c’
1> gen_isr_tables.py: error: multiple registrations at table_index 21 for irq 21 (0x15)
1> Existing handler 0x16d05, new handler 0x57e5
1> Has IRQ_CONNECT or IRQ_DIRECT_CONNECT accidentally been invoked on the same irq multiple times?

Can you help to solve this problem? how can I use two RTC in nRF5340?

Thanks.

Carl

Parents Reply Children
  • Hi    ,

    I am facing similar issue here, not able to use RTC, i tried all you suggestions and attached same code as well, getting below error-

    error: NRFX_RTC (defined at C:/ncs/v2.9.0/zephyr/modules/hal_nordic\nrfx/Kconfig:443,
    modules\hal_nordic\nrfx/Kconfig:443) is assigned in a configuration file, but is not directly user-
    configurable (has no prompt). It gets its value indirectly from other symbols. See
    docs.zephyrproject.org/.../kconfig.html and/or look up NRFX_RTC in the
    menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
    and Kconfig - Tips and Best Practices sections of the manual might be helpful too.

    Please support!

    Thank you!

Related