Hi,
i have a nano connect with some auxiliary circuitry that gets powered from the 3.3v out.
This circuitry needs initialization when powered on. On reset the 3.3v will stay active so no need for initialization.
This is why i need to determine the reason the nano boots. If from brown out/power loss or due to reset keeping power alive.
According to rp2040 documentation page 187 there is a cpu register for that purpose.
My question is how do i read from this register?
thanks
klink
I solved it myself. By digging in some pi pico source files i found something i adapted to my needs.
Its surely not very pretty but works for me...
Maybe someone can pick up on this.
#include "hardware/regs/vreg_and_chip_reset.h"
io_rw_32 *reset_reason = (io_rw_32 *) (VREG_AND_CHIP_RESET_BASE + VREG_AND_CHIP_RESET_CHIP_RESET_OFFSET);
int por;
int run;
void setup() {
// put your setup code here, to run once:
if (!(*reset_reason & VREG_AND_CHIP_RESET_CHIP_RESET_HAD_POR_BITS)) { // POR: Last reset was from the power-on reset or brown-out detection
por = 0;
}
else {
por = 1;
}
if (!(*reset_reason & VREG_AND_CHIP_RESET_CHIP_RESET_HAD_RUN_BITS)) { // RUN: Last reset was from the RUN pin
run = 0;
}
else {
run = 1;
}
}
void loop() {
// put your main code here, to run repeatedly:
}