This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Input pulse width extend using GPIOTE / PPI

Good day

Due to I am very new with NRF chips and I did not find direct answer on forum I require some clarification on that moment...

The task is to detect input pulse ( trailing edge ) of original length 2 us and extend it for <time_us>

For now I have implementation that uses PPI channel: GPIOTE input event lowToHigh + GPIOTE output task TOGGLE( init_low ). When I detect edge -> toggle task fires ( output becomes high ) -> I nrf_delay_us( <time_us> ) in in_event_handler and trigger task manually nrf_drv_gpiote_out_task_trigger( out_pin ) -> pin becomes low. Edge trigger delay is acceptable and is about 400 ns: blue - input signal, yellow - output

        

I plan to improve this implementation with hw timer + PPI to produce <time_us> delay with falling edge

But the question is whether it is possible to implement this using only one pin ?

I successfully get trailing edge detection but when I re-configure input pin for output inside in_event_handler and produce extended pulse I get such picture. Input and output pins are connected with resistor so we get original pulse -> "falldown" while re-configuring -> high level

Parents Reply Children
  • Hi Sigurd

    Thanks for quick reply.

    You want to use 1 GPIO pin for both the input and the output?

    Exactly, I want to use one pin by re-configuring it on the fly

  • Hi,

    you don't need to unconfigure pin, just set output value to 1 and then use nrf_gpio_cfg() to switch direction from input to output and back.

  • Hi,

    thanks for reply  - I did try to implement it in this way

    the problem is only in leading edge delay - there is profit but the problem is still exists. Now the output pin high level differs depending on how it is configured ( nrf_gpio_cfg() or nrf_drv_gpiote_out_init() )

    sdk_config.h

    #define GPIOTE_CONFIG_IRQ_PRIORITY 2

    below best and worst cases

         

    Sorry for delays - please take in account that it is a challenge for now to implement so main tasks may have influence

  • I can't get how your signals are put together.. does pulse source have open-drain output?

    At the end of pulse, you call nrf_gpio_pin_clear then configure_txir_pin - between them you have strong low level. You don't need to change pin state, only configuration. For predictable timings, it's probably better to use GPIOTE with NRF_GPIO_PIN_D0H1 output (not sure because I don't know your schematic).

  • Both plots reflect pin state - original pulse ( high one on the plots ) and generated ( low one but not complete ) have delay between leading edges and that is exactly what I was trying to show on plots

    The delay between leading edges ( ~25 us ) is time between GPIOTE edge detect event -> in_handler invocation ->  series of pin commands ( pin_set and pin_cfg ) before nrf_delay_us()

    The strong level you mentioned is caused because of delay when pin is not reconfigured to output - both plots describe leading edge ( despite of second one is too low to be high )

    But I use commented code

    I get next picture with the same schematic but with longer delay between leading edges