This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Pin 21 always return high

On a custom board, I've got 2 inputs connected to an external pullup and a pad. One in is P12, one on P21.

When I short the pad for P12 with GND, that input read low, that's fine. Otherwise it reads high.

When I do the same for the pad connected to P21, it keeps reading high.

I do not have the flag CONFIG_GPIO_AS_PINRESET set (actually I've put my code that outputs the inputs status in a #ifndef CONFIG_GPIO_AS_PINRESET), and looking at UICR PSELRESET, both are 0xFFFFFFFF.

I've read other issues like https://devzone.nordicsemi.com/f/nordic-q-a/16195/nrf52832-p0-21-reset-pin but it seems like I haven't missed anything...

  • Hi there,

    How are you reading out the PSELRESET registers?

    Could you try do a full chip erase with nRF Command line tools and then flash the fw again.

    nrfjprog -e

    Are you able to use the pin as an output? Can you try to toggle the pin:

    #include <stdbool.h>
    #include <stdint.h>
    #include "nrf_delay.h"
    #include "boards.h"
    #include "nrf_gpio.h"
    
    
    #define PIN 21
    
    int main(void)
    {
      
    
        nrf_gpio_cfg_output(PIN);
    
    
        /* Toggle LEDs. */
        while (true)
        {
          
          nrf_gpio_pin_toggle(PIN);
          
          nrf_delay_ms(500);
        }
    }
    
    
    /**
     *@}
     **/
    

    regards

    Jared

  • Hi Jared,

    Thanks for your answer. I tried your code (and erasing UICR with nrfjprog), and your code causes the measured voltage to toggle between 3.3 and 2.9V (there's an external pullup). So that seems fine.

    However I've then put the following code:

        nrf_gpio_cfg_input(PIN, NRF_GPIO_PIN_NOPULL);
        while (true)
        {
        uint32_t pin_state = nrf_gpio_pin_read(PIN);
            if (pin_state != 1)
            {
          NRF_BREAKPOINT;
            }
        }

    And it never breaks. Yet again, trying with port 12, no problem. I'm starting to suspect the problem could be in hardware, so I tried a 2nd board, and the behaviour is the same. (Also port 12 and port 21 are "identically wired" in the schematics).

  • Hi,

    Jonathan said:
    I tried your code (and erasing UICR with nrfjprog), and your code causes the measured voltage to toggle between 3.3 and 2.9V (there's an external pullup). So that seems fine.

    What size is the pull-up resistor? I would expect the MCU to be able to drive the pin to GND.

    Jonathan said:
    And it never breaks. Yet again, trying with port 12, no problem. I'm starting to suspect the problem could be in hardware, so I tried a 2nd board, and the behaviour is the same. (Also port 12 and port 21 are "identically wired" in the schematics).

    I tried your code on my development kit and it hit the NRF_BREAKPOINT line after I had removed CONFIG_GPIO_AS_PINRESET from the preprocessor definitions: 

    So I would agree that this is probably due to your HW somehow.

    regards

    Jared 

  • I've wired a DK for test, and it works perfectly with it. Hardware it is...

    Thank you Jared for your help!

Related