hello,
void GPIOTE_IRQHandler(void)
{
volatile NRF_TIMER_Type * p_timer;
if ((NRF_GPIOTE->EVENTS_IN[0] == 1) &&
(NRF_GPIOTE->INTENSET & GPIOTE_INTENSET_IN0_Msk))
{
if(nrf_gpio_pin_read(9)==1)
{
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART = 1;
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
{
// Do nothing.
}
p_timer = NRF_TIMER1;
p_timer->MODE = TIMER_MODE_MODE_Timer;
p_timer->PRESCALER = 9; // Prescaler 9 produces 31250 Hz timer frequency => 1 tick = 32 us.
p_timer->BITMODE = TIMER_BITMODE_BITMODE_16Bit; // 16bit
p_timer->TASKS_CLEAR = 1; /
p_timer->TASKS_START = 1; // Start timer.
}
else
{
p_timer->TASKS_CAPTURE[0] = 1;;
timer_left = p_timer->CC[0];
//p_timer->EVENTS_COMPARE[0] = 0;
p_timer->TASKS_STOP = 1; // Stop timer.
}
NRF_GPIOTE->EVENTS_IN[0] = 0;
}
}
i want to run the timer 1 at rising edge and get the timer value at falling edge. TASKS_CAPTURE[0] :capture Timer value to CC[0] rigister. but,i find the value of CC[0] is 0,WHY?