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
Related