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 ....
}
}