Demand: nRF52 Timer operate in 400ns. nRF52 Timer Interrupt response time is too slow!

Hello everyone

 I am using nRF52 DK PCA10040.

 I try to generate puls by Timer 0.

 The puls width is 400ns.

 This goal was failed.

-----------------------------------------------------

I find out  enter timer0 interrupt until leave.

It cost around  730ns~1us .

I traced through disassembly code, the instruction is not too much to over 400ns.

How can I meet the goal? 

It's very important! Thanks.

The code reference as below

================================

void timer_led_event_handler(nrf_timer_event_t event_type, void* p_context)
{
nrf_gpio_pin_write (TEST_OUT1, 1);

}

int main(void)
{

//High Speed//

NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART = 1;
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);

// IO SETUP//

nrf_gpio_cfg_output (TEST_OUT1); //SETUP TEST P1 = OUTPUT

//TIMER SETUP//
NRF_TIMER0->TASKS_STOP = 1;      // Stop timer
NRF_TIMER0->MODE = TIMER_MODE_MODE_Timer; // taken from Nordic dev zone
NRF_TIMER0->BITMODE = (TIMER_BITMODE_BITMODE_08Bit << TIMER_BITMODE_BITMODE_Pos);
NRF_TIMER0->PRESCALER = 0; 
NRF_TIMER0->TASKS_CLEAR = 1;      // Clear timer
NRF_TIMER0->CC[0] = 6; //375ns 
NRF_TIMER0->INTENSET = TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos; // taken from Nordic dev zone
NRF_TIMER0->SHORTS = (TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos);
_NRFX_IRQ_PRIORITY_SET(TIMER0_IRQn,1);
NVIC_EnableIRQ(TIMER0_IRQn);
NRF_TIMER0->TASKS_START = 1; // Start TIMER



while (1)
{
nrf_gpio_pin_write (TEST_OUT1, 0);
};


}

Parents Reply Children
No Data
Related