The GPIO4 could not read the IO level accurately in sense mode.

Hi Nordic

I used the nrf_gpio_cfg_sense_input() API to initialize the GPIO4 for waking up nrf52832 from system off mode, This IO could wake up nrf52832 successfully, but It could not be read accurately when I called nrf_gpio_pin_read() API to read in running mode, The return value of nrf_gpio_pin_read()  was positive value all the time when the actual external voltage to the IO was 0.

There is the same problem in the PCA10040 DK.

Is there any way to use the same IO to wake up chip from system off mode and also can be used to read the IO pin input level?

  • Hello,

    Could you confirm whether you are using the nRF Connect SDK or the nRF5 SDK for your application?
    Could you also tell me, where do you initialize the GPIO to function as a wakeup source?
    To use it as a regular GPIO you can initialize it as such at the start of your program, and then change to use it as a wakeup pin exclusively right before going to SYSTEM_OFF sleep.
    How is this done in your program currently?

    Best regards,
    Karl

  • Hello

    Could you confirm whether you are using the nRF Connect SDK or the nRF5 SDK for your application?

    I am using nRF5 SDK v17.0.2 for the application.

    Could you also tell me, where do you initialize the GPIO to function as a wakeup source?

    I called nrf_gpio_cfg_sense_input() API exclusively to initialize  the GPIO4 at the beginning of the main(),It can not read the GPIO4 input level accurately by the nrf_gpio_pin_read().Could the input level to the GPIO4 be read accurately  when GPIO4 in the sense mode?

    To use it as a regular GPIO you can initialize it as such at the start of your program, and then change to use it as a wakeup pin exclusively right before going to SYSTEM_OFF sleep.

    1)I called nrf_gpio_cfg_sense_input() API exclusively to initialize  the GPIO4 at the beginning of the main(),the GPIO4 is used as a wakeup source and a USB charging detect pin. When plug USB to the board, the GPIO4 pin would be high voltage level and the chip could be waked up from SYSTEM_OFF. And the chip can be succeeded to DFU normally when USB keep to plug to the board(when the GPIO4 is 3.3V). The only one problem in this case is that the GPIO4 could not be used for charging detecting, because it could not read the input level to GPIO4 by calling nrf_gpio_pin_read(), the return value of input level  from nrf_gpio_pin_read() is always high whether the voltage to GPIO4 is high or low.

    2)In the case of to initialize GPIO4 as a regular GPIO at the start of my program and to initialize GPIO4 as a wakeup pin exclusively right before going to SYSTEM_OFF sleep, the chip could not start to DFU normally when USB keep to plug to the board(when the GPIO4 is 3.3V), and nRF Connect App always display information of starting bootloader or connecting. But the chip can be succeed to DFU normally when USB was pulled off the board(when the GPIO4 is 0V).

    All in all, I want the GPIO4 can be used as a wakeup source and to read the level of the pin and not to effect the DFU. If the input voltage level to GPIO4 can be read by calling nrf_gpio_pin_read() when GPIO4 is initialized exclusively by nrf_gpio_cfg_sense_input(), I think this issue would be solved.

  • Hello,

    Thank you for clarifying and elaborating on your project and intentions.

    Tom.Fu said:
    I called nrf_gpio_cfg_sense_input() API exclusively to initialize  the GPIO4 at the beginning of the main(),It can not read the GPIO4 input level accurately by the nrf_gpio_pin_read().Could the input level to the GPIO4 be read accurately  when GPIO4 in the sense mode?

    Yes, it can be used for this, but the difference lies in how you configure and use it. Have you set pullups/pulldowns for the pin?
    For instance, if you need events and tasks on the GPIO you will need to enable the GPIOTE module to do so.

    Otherwise, you will only have the GPIO functionality as described here in the documentation.
    In this case, if you are reading the latched value of the pin you must clear it using the CPU to set to back to low, as stated in the documentation:

    The LATCH register will only be cleared if the CPU explicitly clears it by writing a '1' to the bit that shall be cleared, i.e. the LATCH register will not be affected by a PINx.DETECT signal being set low.

    Tom.Fu said:
    All in all, I want the GPIO4 can be used as a wakeup source and to read the level of the pin and not to effect the DFU. If the input voltage level to GPIO4 can be read by calling nrf_gpio_pin_read() when GPIO4 is initialized exclusively by nrf_gpio_cfg_sense_input(), I think this issue would be solved.

    I would recommend that you then follow the approach used in the ble_peripheral examples - at the beginning of your application you configure the GPIO as you need it during regular operation (as a pulled down pin that you read and clear so and so often), and then you re-configure it as a wakeup pin right before going to SYSTEM_OFF sleep (usually shown in the prepare sleep functions).

    Best regards,
    Karl

Related