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

Connection loss immediately if timer 2 capture value is changed

Hello All ,

I am working on nrf51822 with sdk 7.1.0 and softdevice 7.1.0 .Earlier my ble connection was working very good with no disconnection anytime unless i disconnect it.but now connection is getting lost after 2 to 3 minutes since i have changed the value of NRF_TIMER2->CC[0].

Earlier it was NRF_TIMER2->CC[0] = 62500 and now NRF_TIMER2->CC[0]=625

my timer_init function

void Duration_Timer_Init(void)
{
	
    NRF_TIMER2->MODE            = TIMER_MODE_MODE_Timer;         // Set the timer in Timer Mode
    NRF_TIMER2->TASKS_CLEAR     = 1;                   // clear the task first to be usable for later
	NRF_TIMER2->PRESCALER       =  8;              // Set prescaler. Higher number gives slower timer. Prescaler = 0 gives 16MHz timer
	NRF_TIMER2->BITMODE         = TIMER_BITMODE_BITMODE_16Bit;	 // Set counter to 16 bit resolution
	
	// Enable interrupt on Timer 2 for CC[0] compare match events
	NRF_TIMER2->INTENSET = (TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos);
    NVIC_EnableIRQ(TIMER2_IRQn);
}

this initialization was done for 1 sec ,now i want it to be change to 10msec . so i change the value of NRF_TIMER2->CC[0] = 625 .

what could be the reason for the disconnection. is there any relation between stack and timer2?

thanks & Regards Asma

Parents
  • It could have something to do with the interrupt priorities, please see this.

    The default interrupt priority is 0, but when the SoftDevice is enabled the application should use Application High(1) or Application Low(3). Please see Appendix A SoftDevice architecture, Section "Exception (interrupt) management with a SoftDevice" in the S110 SoftDevice specification v2.0.

    Try doing a sd_nvic_SetPriority(TIMER2_IRQn, NRF_APP_PRIORITY_LOW); after sd_nvic_EnableIRQ(TIMER2_IRQn);

    If it doesn't help please edit your question to include the code where you start the timer, the interrupt request handler.

  • You can create a case in the MyPage support portal, top right corner of our website, and share the project there. This will be private and secure. Or you can edit your question to include some more code. I'm interested in when you are calling this timer init function.

Reply Children
No Data
Related