Hello! I am trying using the nRF52840 and I am having trouble writing a digital output to a pin that I am sharing with the SAADC. When I remove the analogRead, the device can easily output a digital signal to the pin in question. When I have called analogRead, after trying to digitalWrite to the pin, it stays low, but I can see a slight pulses to 1V or so every ~10ms.
When digging deeper, I found the specific code that causes the pin to be unusable as GPIO output is this in wiring_analog_nRF52.c:
NRF_SAADC->CH[0].PSELN = psel; NRF_SAADC->CH[0].PSELP = psel;
So, when trying to disable the connection to the SAADC, I found in this previous post I can remap the PSELP to no connection and then restart the SAADC as such:
NRF_SAADC->CH[0].PSELP = 0; NRF_SAADC->CH[0].PSELN = 0; NRF_SAADC->ENABLE = 1; __NOP(); __NOP(); __NOP(); __NOP(); NRF_SAADC->ENABLE = 0;
This doesn't seem to work, and no matter what I do to the the pin I can't seem to write an output that doesn't get pulled to ground. Am I missing something? Thank you in advance for the help.