My custom nRF52840 board uses the STmicro STM6601 push-button controller. To keep the nRF powered, the PSHOLD line must be kept high. I have a GPIO set as an output for that.
I am trying to incorporate the Open bootloader in my code.
Obviously using a reset (hard or soft) will change that GPIO to an input, causing the PSHOLD line to go low.
I can successfully call the boot loader directly without a reset, but it seems to reset the GPIO pin to an input anyway.
I would like a suggestion on how to keep that GPIO set through the bootloader initialization.
Where in the Open bootloader process does it reset the GPIOs?
Could you tell which GPIO pin you use ?
Note that after a soft reset, a pin will be configured as input with input buffer disconnected. The level of the pin will be high impedance (floating). It's not driven low. You can have an external pull up for the pin.
Note that if you implement the GPIO configuration inside the bootloader, there would be a very short period when the pin is float. And because it's very short (microseconds) you can add a capacitor to keep the pin high during the period if pull up is not an option.
The GPIO is P0.12
When I step through the process using the debugger (from when the app calls the bootloader to when the bootloader enters its main loop), the GPIO stays high.
But when I run it "stand-alone", the output goes low long enough for the system power to go off.
Could you capture an oscilloscope / logic analyzer of the pin ? I want to see how long the pin goes low. Have you tried to put a capacitor / a pull up resistor?
Please make sure there is no code in the bootloader that pull the pin low.
Here the signal from the scope.
Note that the nRF52840 is here powered by the Dev Kit debugger (i.e. SB47 is joined.)
This is necessary so you can see that the signal does indeed go high after the restart.
If I step through the code in the debugger, I don't see anywhere where the output is set low.
Is there any way of telling if the device goes through a reset? Is the nRESET pin bi-directional?