I want to set the GPIO of NRF52840 to the high resistance state. How do I set the GPIO of NRF52840 to the high resistance state, please help me,thanks!
I want to set the GPIO of NRF52840 to the high resistance state. How do I set the GPIO of NRF52840 to the high resistance state, please help me,thanks!
Hello,
Do you mean high impedance / High Z?
If so, then the default state of all GPIOs are high Z which is acheived by putting the GPIO in "Disconnected Input".
How did you change it from disconnected input? Did you use it in a peripheral (UART / SPI / I2C / ...)? In that case, I suggest that you disable whatever peripheral that is using that GPIO, if you can find an uninit() or definit() function. If not, you can put the GPIO settings register back to 0x00000002 manually. How do to that depends on what SDK you are using.
Here is a description of the GPIO's configuration register: https://infocenter.nordicsemi.com/topic/ps_nrf52840/gpio.html?cp=4_0_0_5_8_1_9#register.PIN_CNF-0-31
There exists API to configure this. Based on your case history, it looks like you are using the nRF5 SDK, so let me know if that is not the case this time.
Try using nrfx_gpiote_in_uninit() or nrf_gpio_cfg_default() to clear the configuration of the pin that you want to set to disconnected input.
Best regards,
Edvin
You're right. I'm using a UART peripheral, In fact, the 52840 on the circuit board is connected to a Bluetooth module through a serial port. For faster debugging of the Bluetooth module, the serial port terminal is used to directly communicate with the Bluetooth module. Therefore, I want to set the serial port of 52840 to a high resistance state, that is also high Z. This is what I set up in the program,
But it didn't seem to work, how do I set it?
Still not sure what SDK you are using, but I will assume it is the nRF5 SDK until you say otherwise.
If you initialized the UART using APP_UART_FIFO_INIT() or app_uart_init(), try to uninit the UART first using app_uart_close().
If you used another way to initialize the UART, then see if the file that implemented the init function has an equivalent uninit function.
As you can see in app_uart_close() -> nrfx_uarte_uninit(), it will first disable the uart, and then set the pins to the default state:
I am not sure how the UART drivers would behave if you try to take it's gpios while it is active.
Best regards,
Edvin
Thank you very much, the problem had solved, my code is correct.