This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Bluetooth service stops after some time

Hi,

Im using SD5 and after some time (every time different) of transmitting HRS data the SD stops apparently, because there is no more connection with my Android phone and the device becomes invisible as well.

It only happens when I use Timer2 to generate PWM however.

So here is my timer interrupt and init functions:

void TIMER2_IRQHandler()
{
	
	if(beepOn && makeBeep>0 && NRF_TIMER2->EVENTS_COMPARE[1]!=0)
	{
		if(beepCycles%2==0)
		{
			nrf_gpio_pin_toggle(BEEPER_PIN);
		}
		beepCycles++;
		if(beepCycles==120)
		{
			beepCycles=0;
			makeBeep--;
			nrf_gpio_pin_clear(BEEPER_PIN);
		}
		
	}
	if(NRF_TIMER2->EVENTS_COMPARE[1]!=0)NRF_TIMER2->EVENTS_COMPARE[1]=0;





static void pwm_timer_init(void)
{
    
    NRF_TIMER2->MODE        = TIMER_MODE_MODE_Timer;
    NRF_TIMER2->BITMODE     = TIMER_BITMODE_BITMODE_16Bit << TIMER_BITMODE_BITMODE_Pos;
    NRF_TIMER2->PRESCALER   = 0;

    // Clears the timer, sets it to 0.
    NRF_TIMER2->TASKS_CLEAR = 1;

    
    NRF_TIMER2->CC[0] = 355;
		
NRF_TIMER2->SHORTS = (TIMER_SHORTS_COMPARE1_CLEAR_Enabled << TIMER_SHORTS_COMPARE1_CLEAR_Pos) & TIMER_SHORTS_COMPARE1_CLEAR_Msk;
     

		
    NRF_TIMER2->CC[1] = 8000;
NRF_TIMER2->CC[2] = 0;
    // Interrupt setup.
    NRF_TIMER2->INTENSET = (TIMER_INTENSET_COMPARE1_Enabled << TIMER_INTENSET_COMPARE1_Pos);
		
		NRF_TIMER2->EVENTS_COMPARE[0]=NRF_TIMER2->EVENTS_COMPARE[1]=NRF_TIMER2->EVENTS_COMPARE[2]=0;

    // Enable interrupt on Timer 2.
		
		
	
 sd_nvic_SetPriority(TIMER2_IRQn, PWM_IRQ_PRIORITY | 0x01);
   sd_nvic_EnableIRQ(TIMER2_IRQn);

    // Start the timer.
    NRF_TIMER2->TASKS_START = 1;

}

The app_error_handler is never called, but if I stop a debug session, I get the following:

SD error on stop

Any ideas what could be wrong?

Thanks, Sergey

Related