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

Using two GPIOTE config to a single pin

In another thread entitled:

Change in GPIO to start/stop timer and fire interrupt

The following code is used:

  NRF_GPIOTE->CONFIG[0] = (GPIOTE_CONFIG_POLARITY_HiToLo << GPIOTE_CONFIG_POLARITY_Pos)
        | (myPin << GPIOTE_CONFIG_PSEL_Pos) // using GPIO 5 as input
        | (GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos);

    //// Configure GPIOTE channel 1 as event that occurs when pin 5 changes from digital
    //// low to hi.
    NRF_GPIOTE->CONFIG[1] = (GPIOTE_CONFIG_POLARITY_LoToHi << GPIOTE_CONFIG_POLARITY_Pos)
        | (myPin<< GPIOTE_CONFIG_PSEL_Pos) // using GPIO 5 as input
        | (GPIOTE_CONFIG_MODE_Event << GPIOTE_CONFIG_MODE_Pos);

In the nRF51 RM, there is a statement: Each GPIOTE channel is associated with one physical GPIO pin through the CONFIG.PSEL field...

Is the above code breaking this rule? Are two configurations being mapped to a single pin?

Would the correct code be to look for a change, then check the PIN state in the ISR to determine whether it was HiToLo or LoToHi?

If so, what would be the recommended debounce approach?

Parents
  • None of this is Cortex-M0-specific. By 'input' I meant the signal you are trying to measure transitions on, the actual signal line. Pin means the logical number of input/output connection on the chip, eg P0.23, which of course then confusingly maps to a physical pin on the device.

    The spec-compliant way to do it is to have the input signal route to two separate pins and have the GPIOTE monitor one pin for up transitions and one for down transitions. GPIOTE has two modes, in TASK mode it controls a pin output, it's pretty clear you can't have two GPIOTEs driving a pin, in EVENT mode it monitors a pin, it seems reasonable that two GPIOTEs could monitor events on the same pin and empirically that works, but does violate the letter of the documentation. So your options are to find a way to send the same signal to separate pins, to use the fact EVENT mode seems to work,

Reply
  • None of this is Cortex-M0-specific. By 'input' I meant the signal you are trying to measure transitions on, the actual signal line. Pin means the logical number of input/output connection on the chip, eg P0.23, which of course then confusingly maps to a physical pin on the device.

    The spec-compliant way to do it is to have the input signal route to two separate pins and have the GPIOTE monitor one pin for up transitions and one for down transitions. GPIOTE has two modes, in TASK mode it controls a pin output, it's pretty clear you can't have two GPIOTEs driving a pin, in EVENT mode it monitors a pin, it seems reasonable that two GPIOTEs could monitor events on the same pin and empirically that works, but does violate the letter of the documentation. So your options are to find a way to send the same signal to separate pins, to use the fact EVENT mode seems to work,

Children
No Data
Related