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

How could I reduce power consumption after using NRF_TIMER1 with SoftDevice ?

FormerMember
FormerMember

Hi.

I want to active HW timer with SoftDevice 7.1.0 . Timer operation is good but I can not stop the timer. The power consumption is 200~300uA after timer expired ( or stop ) I should reduce to power consumption under 5uA.

I think SoftDevice use NRF_TIMER0 and it may be conflict power control at SoftDevice . Should I send some information to SoftDevice when I want to use NRF_TIMER1 or NRF_TIMER2?

Could you check my code ?

 #define Melody_Duration_Timer			    NRF_TIMER1

 #define Melody_Duration_IRQHandler          TIMER1_IRQHandler

 #define Melody_Duration_IRQn                TIMER1_IRQn



// start code 

void melody_duration_timer_init(int duration_ms)
{

	app_trace_log("melody_duration_timer_start\r\n");

	Melody_Duration_Timer->POWER=1;
	Melody_Duration_Timer->MODE = TIMER_MODE_MODE_Timer;	            
	Melody_Duration_Timer->BITMODE = TIMER_BITMODE_BITMODE_16Bit;
	Melody_Duration_Timer->PRESCALER = 9;
	Melody_Duration_Timer->TASKS_CLEAR = 1;
	Melody_Duration_Timer->SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Msk;
       Melody_Duration_Timer->EVENTS_COMPARE[0]
         = Melody_Duration_Timer->EVENTS_COMPARE[1] 
         = Melody_Duration_Timer->EVENTS_COMPARE[2] 
         = Melody_Duration_Timer->EVENTS_COMPARE[3] = 0;     

	Melody_Duration_Timer->CC[0] =	duration_ms * tick_per_ms;

	apply_pan73_workaround(Melody_Duration_Timer, true);
	Melody_Duration_Timer->INTENSET = (TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos);
	  
	NVIC_EnableIRQ(Melody_Duration_IRQn);
	Melody_Duration_Timer->TASKS_START = 1;			
}


// stop code

void melody_duration_timer_stop(void)
{

	Melody_Duration_Timer->TASKS_STOP = 1;

	Melody_Duration_Timer->TASKS_CLEAR = 1;

    Melody_Duration_Timer->EVENTS_COMPARE[0] 
		= Melody_Duration_Timer->EVENTS_COMPARE[1] 
		= Melody_Duration_Timer->EVENTS_COMPARE[2] 
		= Melody_Duration_Timer->EVENTS_COMPARE[3] = 0;     
	
	Melody_Duration_Timer->CC[0] = 0;
	Melody_Duration_Timer->SHORTS = 0;
	Melody_Duration_Timer->INTENSET = 0;
//	Melody_Duration_Timer->TASKS_SHUTDOWN = 1; 
//	Melody_Duration_Timer->POWER=0;
	
	NVIC_DisableIRQ(Melody_Duration_IRQn);
}


void Melody_Duration_IRQHandler(void)

{

	if ((Melody_Duration_Timer->EVENTS_COMPARE[0] != 0) 
           && ((Melody_Duration_Timer->INTENSET & TIMER_INTENSET_COMPARE0_Msk) != 0))

	{
		Melody_Duration_Timer->EVENTS_COMPARE[0] = 0;
               Do something ....
	}

}
Parents
  • Hi,

    I do not see anything wrong with your code except

    • the mysterious duration_ms and ticks_in_ms variables which i cannot guess their values.
    • You need to disabled the workaround for PAN73 when you are not using the timer, this is explicitly said in the document. For your case you need to add this below line in timer_shutdown function

    Melody_Duration_Timer->TASKS_STOP = 1;
    *(uint32_t *)0x40009C0C = 0; //for Timer 1

Reply
  • Hi,

    I do not see anything wrong with your code except

    • the mysterious duration_ms and ticks_in_ms variables which i cannot guess their values.
    • You need to disabled the workaround for PAN73 when you are not using the timer, this is explicitly said in the document. For your case you need to add this below line in timer_shutdown function

    Melody_Duration_Timer->TASKS_STOP = 1;
    *(uint32_t *)0x40009C0C = 0; //for Timer 1

Children
No Data
Related