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

Rtc is not working in Ble_app_multilink_central

Hi all,

I am developed application so that it is communicate with save device, i can able to send data from master to slave. In Ble_app_multilink_central master side code, if i use rtc, master is not connecting to slave. If i comment Rtc part i can able to communicate with slave device. I am using s120_nrf51822_1.0.0_softdevice for master code.
here is my RTC code: static void lfclk_config(void) { NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos); NRF_CLOCK->EVENTS_LFCLKSTARTED = 0; NRF_CLOCK->TASKS_LFCLKSTART = 1; while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) { //Do nothing. } NRF_CLOCK->EVENTS_LFCLKSTARTED = 0; }

/** @brief Function for configuring the RTC with TICK to 100Hz and COMPARE0 to 10 sec. */ static void rtc_config(void) { NVIC_EnableIRQ(RTC0_IRQn); // Enable Interrupt for the RTC in the core. NRF_RTC0->PRESCALER = COUNTER_PRESCALER; // Set prescaler to a TICK of RTC_FREQUENCY. NRF_RTC0->CC[0] = COMPARE_COUNTERTIME * RTC_FREQUENCY; // Compare0 after approx COMPARE_COUNTERTIME seconds.

// Enable COMPARE0 event and COMPARE0 interrupt:
NRF_RTC0->EVTENSET = RTC_EVTENSET_COMPARE0_Msk;
NRF_RTC0->INTENSET = RTC_INTENSET_COMPARE0_Msk;
	 

}

/** @brief: Function for handling the RTC0 interrupts.

  • Triggered on TICK and COMPARE0 match. */ void RTC0_IRQHandler() {

    if ((NRF_RTC0->EVENTS_COMPARE[0] != 0) && ((NRF_RTC0->INTENSET & RTC_INTENSET_COMPARE0_Msk) != 0)) { NRF_RTC0->EVENTS_COMPARE[0] = 0; NRF_RTC0->CC[0] = NRF_RTC0->CC[0]+(COMPARE_COUNTERTIME * RTC_FREQUENCY); // nrf_gpio_pin_toggle(GPIO_TOGGLE_COMPARE_EVENT); } }

If i add this code into central code and debugged the code, at that time it is going to this part. HardFault_Handler
PROC EXPORT HardFault_Handler [WEAK] B . ENDP

Can any one please help me on this why it is behaving like this.

Regards Manjunath

Parents
  • Hi,

    I got this , Now my rtc is working fine but, if i send data to slave in rtc handler it is not working. it may hanging in rtc interrupt. But connection is happens and unable to send data to slave device. here is code: if ((NRF_RTC1->EVENTS_COMPARE[0] != 0) && ((NRF_RTC1->INTENSET & RTC_INTENSET_COMPARE0_Msk) != 0)) { NRF_RTC1->EVENTS_COMPARE[0] = 0; NRF_RTC1->CC[0] = NRF_RTC1->CC[0]+(COMPARE_COUNTERTIME * RTC_FREQUENCY); // nrf_gpio_pin_toggle(GPIO_TOGGLE_COMPARE_EVENT); nrf_gpio_pin_toggle(19); //this state not changing, only once toggled. if(flag == 0) { char_write(0x14,0x13); // sending data to slave. flag =1; nrf_gpio_pin_set(19); }else { char_write(0x00,0x13); flag =0; nrf_gpio_pin_clear(19); }

    } 
    
  • FormerMember
    0 FormerMember in reply to Manjunath

    Which error code do you get when you try to send data to the salve?

Reply Children
No Data
Related