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
  • Hi,

    Maybe you can try this instead, snippet:

    	
    	IRQ_CONNECT(RTC0_IRQn, NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY,
    		nrfx_rtc_0_irq_handler, NULL, 0);
    
    			IRQ_CONNECT(RTC1_IRQn, NRFX_RTC_DEFAULT_CONFIG_IRQ_PRIORITY,
    		nrfx_rtc_1_irq_handler, NULL, 0);

    (If this does not work either, then please upload your project.)

  • By the way, I already used 3 timers and 1 GPIO as below:

    IRQ_CONNECT(DT_IRQN(DT_NODELABEL(timer0)),
    DT_IRQ(DT_NODELABEL(timer0), priority),
    nrfx_isr, nrfx_timer_0_irq_handler, 0);

    IRQ_CONNECT(DT_IRQN(DT_NODELABEL(timer1)),
    DT_IRQ(DT_NODELABEL(timer1), priority),
    nrfx_isr, nrfx_timer_1_irq_handler, 0);

    IRQ_CONNECT(DT_IRQN(DT_NODELABEL(timer2)),
    DT_IRQ(DT_NODELABEL(timer2), priority),
    nrfx_isr, nrfx_timer_2_irq_handler, 0);

    IRQ_CONNECT(DT_IRQN(DT_NODELABEL(gpiote)),
    DT_IRQ(DT_NODELABEL(gpiote), priority),
    nrfx_isr, nrfx_gpiote_irq_handler, 0);

    Is this the reason why I got those errors when I tried to register the second RTC?

    Thanks.

    Carl..

Reply
  • By the way, I already used 3 timers and 1 GPIO as below:

    IRQ_CONNECT(DT_IRQN(DT_NODELABEL(timer0)),
    DT_IRQ(DT_NODELABEL(timer0), priority),
    nrfx_isr, nrfx_timer_0_irq_handler, 0);

    IRQ_CONNECT(DT_IRQN(DT_NODELABEL(timer1)),
    DT_IRQ(DT_NODELABEL(timer1), priority),
    nrfx_isr, nrfx_timer_1_irq_handler, 0);

    IRQ_CONNECT(DT_IRQN(DT_NODELABEL(timer2)),
    DT_IRQ(DT_NODELABEL(timer2), priority),
    nrfx_isr, nrfx_timer_2_irq_handler, 0);

    IRQ_CONNECT(DT_IRQN(DT_NODELABEL(gpiote)),
    DT_IRQ(DT_NODELABEL(gpiote), priority),
    nrfx_isr, nrfx_gpiote_irq_handler, 0);

    Is this the reason why I got those errors when I tried to register the second RTC?

    Thanks.

    Carl..

Children
Related