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

Unable to use gpio reset pin as a gpio in nrf connect sdk

Hi,

I am not able to use the gpio pin p0.18 as a gpio with nrf connect sdk.

I have tried to toggle the pin using "gpio_pin_toggle" and gpio_pin_set" functions but it is not working. (These functions returns 0)

I want to use it as a chip select pin for my peripheral, all other lines are working except the gpio p0.18.

I have disabled the reset functionality  from the manuconf option. I have also tried to add CONFIG_GPIO_AS_PINRESET=n to the project config file but no luck.

As i can see in the zephyr.dts file, qdec interrupt pin also have the same number. (qdec is in disabled state in board.dts file). Would this be causing the problem ?

fyi, i have made sure the hardware is working by running sdk5 based code.

8863.zephyr.dts

I have tested it using the blinky example from zephyr samples.

Board: custom board based on nrf52840.

  • Not sure if this helps, but the reset pin configuration is one-way; once set as a reset pin the only way to unset and use as a port pin is to do a flash erase all, and reprogram. This example is SDK not nRFConnect for nRF52832 but nRF52840 is similar with port P0.18 instead:

        /* Configure GPIO pads as pPin Reset pin if Pin Reset capabilities desired. If CONFIG_GPIO_AS_PINRESET is not
          defined, pin reset will not be available. One GPIO (see Product Specification to see which one) will then be
          reserved for PinReset and not available as normal GPIO. */
        #if defined (CONFIG_GPIO_AS_PINRESET)
            if (((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos)) ||
                ((NRF_UICR->PSELRESET[1] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos))){
                NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; // Write Enable
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_UICR->PSELRESET[0] = 21;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_UICR->PSELRESET[1] = 21;
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; // Read-only Enable
                while (NRF_NVMC->READY == NVMC_READY_READY_Busy){}
                // UICR changes require a reset to be effective
                NVIC_SystemReset();
            }
        #endif

  • hi Hmolesworth,

    Thanks for the reply.

    I don't really want to add direct register access to the application code and wish to do it with zephyr apis/configurations itself. (without using any lower layer codes mainly because it can cause porting issues.)

    There should be some other ways to get it done without directly accessing the registers(hope so). In worst case, i will try this out.

    fyi: It is already working with my nrf5 sdk based code.

  • Hi!

    From your devicetree, it looks like botoh SPI3 and the Arduino connector are defined correctly. Could you show me all the application configurations and how you're initializing the SPI in your application?

  • Thank you  Heidi,

    I have found that ' west flash ' is writing to UICR register to enable pin reset, which was causing the problem.

    I have  got it fixed by using,

    nrfjprog -e && west flash --softreset,

    Or by using nrfjprog --family nRF52 --program

    I This looks like a serious issue and i wonder why does the west tool is updating the UICR registers.

    Thanks for the support.

  • Hello ,

    I recognized the same as madblue. If using VSCode and the NRF Connect SDK Extension the flash function writes to the UICR, even if 

    CONFIG_GPIO_AS_PINRESET=n

    is set. I have erased the flash before and validated the UICR being all 0xFF, then just used flash functionality from the extension.

    Is there any solution available?

Related