Any PMU Sleep / Software Reset Example?

Is there any example code available which shows how to set a hifive1revb in sleep mode using the aon domain (pmu and wake-up cause rtc) and proper start-up code?


You can use these two functions (or re-implement them in your code) to sleep for a few seconds:
Note that sleep/wake programs are different for FE310-G000 and FE310-G002.

Thank you very much.

After sleep (self.pmusleep.write(|w| w.sleep().set_bit()); or AON_REG(AON_PMUSLEEP) = 1;) the board should sleep and wake by reset, shouldn’t it? Any idea what’s wrong with this code? Does not go into sleep mode.

AON_REG(AON_RTCCFG) |=  0x0000100f;
uint32_t now = AON_REG(AON_RTCS);
// some time
uint32_t then = now + 10;
// send to sleep
// unlook, ch. 14.3
// sleep, ch 14.5

Have you configured a sleep “program” for your board? Other than that part, your code looks the same as the Rust code I posted.

Strange. The board seems to go into sleep when I run the code in the debugger but awakes without considering the timer - which I checked counts correctly - or button. And when awake runs into some deadbeef. Actually, it does not finds its way after awakening into my _start and main function. Could this be some issue with the bootloader? I don’t get it.

And though the board starts from the debugger, it does not run execute my flashed program after reset? Maybe this is the issue.

I crashed the bootloader. After restoring the bootloader, it works finally.