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

RTC1 compare1 channel without interrupt

I want to make a rtc calendar.As rtc1 compare channel 0 had been used by app_timer,so I use rtc1 compare channel 1 to generate interrupt very second. But the channel 1 didn't generate interrupt. Here is the configuration.

//channel 0 for app_timer static void rtc1_start(void)

{

if( !m_rtc1_time_tick ) /jam/

{

NRF_RTC1->EVTENSET = RTC_EVTEN_COMPARE0_Msk;
NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE0_Msk;
 NRF_RTC1->EVENTS_COMPARE[0] = 0;

NVIC_ClearPendingIRQ(RTC1_IRQn);
NVIC_EnableIRQ(RTC1_IRQn);

NRF_RTC1->TASKS_START = 1;
nrf_delay_us(MAX_RTC_TASKS_DELAY);

 }

else /jam/

{

NVIC_DisableIRQ(RTC1_IRQn);
 
 NRF_RTC1->EVTENSET = RTC_EVTEN_COMPARE0_Msk;
NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE0_Msk;
 NRF_RTC1->EVENTS_COMPARE[0] = 0;
 
 NRF_RTC1->TASKS_START = 1;
nrf_delay_us(MAX_RTC_TASKS_DELAY);
 
 NVIC_EnableIRQ(RTC1_IRQn);

}

m_rtc1_running = true;

}

//channel 1 for second calendar void rtc1_second_start(void)

{

if( !m_rtc1_running ) /jam/

{

NRF_RTC1->EVTENSET = RTC_EVTEN_COMPARE1_Msk;
NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE1_Msk;
 NRF_RTC1->EVENTS_COMPARE[1] = 0;
 NRF_RTC1->CC[1] = BLE_SYSTEM_CLOCK_EVET_PERIOD;

NVIC_ClearPendingIRQ(RTC1_IRQn);
NVIC_EnableIRQ(RTC1_IRQn);

NRF_RTC1->TASKS_START = 1;
nrf_delay_us(MAX_RTC_TASKS_DELAY);

 }

else /jam/

{

NVIC_DisableIRQ(RTC1_IRQn);
 
 NRF_RTC1->EVTENSET = RTC_EVTEN_COMPARE1_Msk;
NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE1_Msk;
 NRF_RTC1->EVENTS_COMPARE[1] = 0;
 NRF_RTC1->CC[1] = BLE_SYSTEM_CLOCK_EVET_PERIOD;
 
 NRF_RTC1->TASKS_START = 1;
nrf_delay_us(MAX_RTC_TASKS_DELAY);
 
 NVIC_EnableIRQ(RTC1_IRQn);

}

m_rtc1_time_tick = true;

}

//interrupt handler void RTC1_IRQHandler(void)

{

if( NRF_RTC1->EVENTS_COMPARE[0] != 0 )

{ NRF_RTC1->EVENTS_COMPARE[0] = 0;

  // Check for expired timers
timer_timeouts_check();

}

if( NRF_RTC1->EVENTS_COMPARE[1] != 0 )

{ NRF_RTC1->EVENTS_COMPARE[1] = 0; NRF_RTC1->CC[1] = BLE_SYSTEM_CLOCK_EVET_PERIOD;

 if( m_rtc1_time_tick )
 {
  if( !clock_int_flag )
   {
   clock_int_flag = true;
  }
  //clock_second_tick++;        //for revise
  //systemFlag4 |= SECOND_CARRY_FLAG;
  //set_system_event( SBP_SECOND_CARRY_EVT );

 }

}

// Clear all events (also unexpected ones)
NRF_RTC1->EVENTS_COMPARE[2] = 0;
NRF_RTC1->EVENTS_COMPARE[3] = 0;
//NRF_RTC1->EVENTS_TICK       = 0;
//NRF_RTC1->EVENTS_OVRFLW     = 0;

}

Parents Reply Children
No Data
Related