Hi
I use the nRF51 Development Kit and the pin_change_int example.
when i push the button the LED changes but there is a delay of 16us.
is this normal ? can i speed this up ?
Blue is the Button Signal
Red is the LED signal
Hi
I use the nRF51 Development Kit and the pin_change_int example.
when i push the button the LED changes but there is a delay of 16us.
is this normal ? can i speed this up ?
Blue is the Button Signal
Red is the LED signal
Hi,
The interrupt latency for the Cortex M0 is 16 cycles == 1 us @ 16M.
The remainder of the time is processing in the nrf_drv_gpiote library (interrupt handler), as this library handles both PORT and IN[n] events. The PORT event uses the SENSE functionality, which is a level trigged signal, not a edge-trigged signal. In order to detect toggle operations, you emulate edge-triggering by inverting the SENSE (going from HIGH to LOW polarity), which may account for the processing time.
You can switch to use the IN[n] events by setting "high accuracy" when configuring your pin, which shall decrease processing time needed: GPIOTE_CONFIG_IN_SENSE_TOGGLE(true)
GPIOTE IN[n] usage does use more current than the PORT event.
If this is too much of a jitter, I'd recommend that you implement GPIOTE PORT directly, like done here: https://github.com/NordicPlayground/nrf51-powerdown-examples/blob/master/system_on_wakeup_on_gpio/main.c
Best regards,
Håkon
Hi,
Thanks this works perfect !
Much faster.
Just another question.
is it possible to change direction with this pin configuration ?
nrf_gpio_cfg_sense_input(ONEWIRE_DATA_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW); // OneWire data Pin
as i did before with ?
nrf_gpio_pin_dir_set(ONEWIRE_DATA_PIN, GPIO_PIN_CNF_DIR_Output); // One Wire Direction output
Best regards,
Markus
Yes, this will change the GPIO from input to an output. Do note that GPIOTE PORT (or IN[n] for that matter) only works if it's an input.
hmm OK
in my interrupt i do
LED_ON;
nrf_gpio_pin_dir_set(ONEWIRE_DATA_PIN, GPIO_PIN_CNF_DIR_Output); // One Wire Direction output
nrf_delay_us(60);
nrf_gpio_pin_dir_set(ONEWIRE_DATA_PIN, GPIO_PIN_CNF_DIR_Input); // One Wire Direction Input
LED_OFF;
but after that the interrupt wont work again.
OK with
nrf_gpio_pin_dir_set(ONEWIRE_DATA_PIN, GPIO_PIN_CNF_DIR_Output); // One Wire Direction output
nrf_delay_us(60);
nrf_gpio_cfg_sense_input(ONEWIRE_DATA_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW); // OneWire data Pin Input
all works !
Thanks