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

Bluetooth and RTC0 error

I wanna execute rtc0 on the project which is inside examples\ble_peripheral\ble_app_uart file in sdk 11 When i write the following codes ,nrf51 is locked.bluetooth connection is not working and does not operate interrupt function Codes

        static void rtc0_init()
    {
    // Internal 32kHz RC
    NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos;
    // Start the 32 kHz clock, and wait for the start up to complete
    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
    
    // Configure the RTC to run at 1 second intervals, and make sure COMPARE0 generates an interrupt (this will be the wakeup source)
    NRF_RTC0->PRESCALER = 0;
    NRF_RTC0->EVTENSET = RTC_EVTEN_COMPARE0_Msk; 
    NRF_RTC0->INTENSET = RTC_INTENSET_COMPARE0_Msk; 
    // NORDIC: Count to 32767, and not 32768
    NRF_RTC0->CC[0] = 1*32767;
    
    NVIC_EnableIRQ(RTC0_IRQn);
    // NORDIC: SET IRQ PRIORITY
    NVIC_SetPriority(RTC0_IRQn, 0);
    
    NRF_RTC0->TASKS_START = 1;
    }

    void RTC0_IRQHandler(void)
    {
    
          // NORDIC: CLEAR TASK AS QUICKLY AS POSSIBLE
        NRF_RTC0->TASKS_CLEAR = 1;
        // This handler will be run after wakeup from system ON (RTC wakeup)
        if(NRF_RTC0->EVENTS_COMPARE[0])
        {
                  NRF_RTC0->EVENTS_COMPARE[0] = 0;
         
        }
    }

int main(void)
{	
    uint32_t err_code;
    bool erase_bonds;
    // Initialize.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
    uart_init();
    printf("\r\nUART Start!\r\n");
    buttons_leds_init(&erase_bonds);
    ble_stack_init();
    gap_params_init();
    services_init();
    advertising_init();
    conn_params_init();

//   
  err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
   APP_ERROR_CHECK(err_code);


   rtc0_init();

    for (;;)
    {
       power_manage();		
    }
}

But when i make the following lines comment lines,then rtc0 interrupt starts working

int main(void)
{
	
    uint32_t err_code;
    bool erase_bonds;

    // Initialize.
   // APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
  // uart_init();
   //  printf("\r\nUART Start!\r\n");
  // buttons_leds_init(&erase_bonds);
  // ble_stack_init();
  // gap_params_init();
   // services_init();
   // advertising_init();
  // conn_params_init();

//   
//   err_code = ble_advertising_start(BLE_ADV_MODE_FAST);
//   APP_ERROR_CHECK(err_code);

   rtc0_init();

What is your suggestion to solve this problem?

Thank You.

Related