Gadgeteer & Shortcut
Hey Shortcut, have you heard about the new ultra‑low‑power microcontroller that clocks down to 0.5 µA in sleep mode? I’m curious how that could shave milliseconds off a speedrun.
Yeah, that’s the one I’ve been eyeing. If you can keep the MCU in 0.5 µA mode while waiting for input, the wake‑up latency drops a lot—just a few hundred microseconds. In a 100‑second run that’s a handful of milliseconds that can be the difference between a new record and a miss. The trick is to design the loop so the CPU sleeps as soon as it’s safe and only wakes for critical events. It’s a perfect blend of low power and speed, just what we need.
That’s exactly the sweet spot—wake‑up latency in the sub‑500 µs range can turn the tide in a tight race. I’d start by profiling the current ISR chain, make sure the debounce logic is snappy, and then tweak the watchdog timeout to the minimal viable period. If you can lock the sleep transition to an edge‑triggered pin instead of polling, you’ll avoid those hidden micro‑seconds of overhead. Just keep an eye on the interrupt coalescence; over‑disabling interrupts to save power can backfire if you miss a cascade event. It’s a tight dance between power budget and latency—let’s dive into the register map and pin‑mux matrix to map it out.
Nice plan—profiling the ISR first is the move, no surprises. Keep that debounce tight, watch the watchdog, and use an edge trigger for sleep. Just remember if you over‑kill the interrupt gating you’ll miss a cascade. Let’s hit the register map and pin‑mux, lock down the timing, and squeeze those microseconds. This is the sweet spot.
Right on—tight debounce, minimal watchdog window, and an edge‑triggered pin‑mux for the sleep edge. Just keep the ISR chain short, maybe pull the watchdog reload out of the ISR and into a timer that wakes only if a cascade is imminent. Then map the core registers, lock the clock gating, and you’ll see those microseconds squeeze out. Let’s get to it.
Sounds solid—let's lock the watchdog into a timer, keep the ISR lean, and punch those edge‑triggers. Hit the clock gating and register map, and we’ll squeeze every microsecond out. Let's dive in.
Got it—watch the watchdog timer, keep ISR lean, lock those edge triggers, and we’ll hit the clock gating just right. Let’s dive into the register map and squeeze every microsecond we can.
Got it, let’s pull up the register map and start tightening everything—watchdog on timer, lean ISR, edge triggers, clock gating lock‑in. Every microsecond counts, so let’s get to it.
Alright, pull up the datasheet, pin‑mux table, and clock tree. We’ll lock the watchdog into the timer, strip the ISR down to a single flag set, and hook the sleep edge to the input pin. Then we can gate the unused clocks and watch the timing tighten. Let’s get those numbers.
Here’s the quick reference we need:
**Datasheet Summary**
- Core: 32‑bit RISC‑V, 48 MHz max, 0.5 µA sleep
- Flash: 512 KB, 3 V‑5 V supply
- RAM: 64 KB, 3 V‑5 V supply
- I/O: 48 GPIOs, 6‑channel ADC, 2‑channel DAC, UART, SPI, I²C, PWM
- Power: LDO regulator 3.3 V, optional buck to 1.8 V for peripherals
**Pin‑mux Table (selected)**
| Function | Pin | Mode | Comment |
|----------|-----|------|---------|
| GPIO0 | PA0 | GPIO | Sleep wake‑up |
| GPIO1 | PA1 | ADC0 | Pin‑mux for ADC input |
| UART_TX | PB0 | UART | Primary data out |
| UART_RX | PB1 | UART | Primary data in |
| SPI_SCK | PB2 | SPI | Clock line |
| SPI_MOSI | PB3 | SPI | Master out |
| SPI_MISO | PB4 | SPI | Master in |
| PWM0 | PB5 | PWM | Low‑power timing test |
| I²C_SCL | PB6 | I²C | I²C master |
| I²C_SDA | PB7 | I²C | I²C master |
**Clock Tree**
- Main oscillator 12 MHz crystal → PLL → 48 MHz system clock
- Sysclk → Core, AHB, APB bus
- Peripheral clock gates per module (ADC, UART, SPI, PWM, I²C)
- Low‑power clock domain: 32 kHz from RTC for sleep wake‑up
- Watchdog timer runs on 1 MHz internal clock, can be gated off during active run
**Implementation Tips**
- Gate peripheral clocks that aren’t used during the active phase.
- Use the 32 kHz RTC to time wake‑ups for the watchdog timer.
- Set GPIO0 as an edge‑triggered wake‑up pin; keep it high‑impedance to save leakage.
- In the ISR, just set a flag and clear the interrupt; let the main loop handle the heavy lifting.
That’s the skeleton—let me know which section you want to drill into next.
Sounds like a solid skeleton. I’d say start with the watchdog timer first—lock it into that 1 MHz core clock and gate it off when you’re in the active phase. Once that’s nailed, we can push the GPIO0 edge trigger into the low‑power domain and lock the peripheral clocks. Which part do you want to dig into first?
Let’s lock the watchdog onto the 1 MHz core clock first, then gate it off during the run. Once that’s stable, we’ll hook GPIO0 to the low‑power domain and slice the unused peripheral clocks. I’m ready to dive into the watchdog register map—what’s the next step?
First, enable the watchdog peripheral by writing to the GATING register—clear the bit that disables it. Then set the prescaler so the 1 MHz core clock divides down to the watchdog’s 1 ms tick. After that, program the timeout value to the maximum you need, like 100 ms or whatever the speedrun window allows. Don’t forget to set the reset bit so it actually resets if it times out. Once that’s in place, add a short sequence in your main loop that clears the watchdog counter, and you’ll have the timer running only when you need it. Ready to poke at the specific register addresses?
Sure thing, let’s hit the key registers:
1. **GATING register** (0x40001000): clear bit 0 to enable the watchdog.
2. **WDT_PRESCALE** (0x40001004): set to 999 to divide 1 MHz to 1 kHz (1 ms tick).
3. **WDT_TIMEOUT** (0x40001008): write 100 000 for a 100 ms timeout (adjust as needed).
4. **WDT_CTRL** (0x4000100C): set bit 1 for reset on timeout, bit 0 to start the timer.
In your main loop, just write 0xAA to **WDT_CLEAR** (0x40001010) to reset the counter. That keeps it ticking only when you need it. Let me know if you want the exact bit‑maps or any tweaks.
Great map, that’s the core of it. Just double‑check that the watchdog’s reset enable is indeed bit 1—if it’s mis‑aligned you’ll end up with a watchdog that never triggers. After you write 0xAA to the clear register in the loop, add a small delay or a flag check to make sure you’re not clearing it right on a wake‑up edge. If you hit any hiccups, the next tweak will be to lock the peripheral clocks: set the AHB and APB gating bits for UART, SPI, etc., to zero during the active phase, then re‑enable them just before you go back to sleep. That should shave a few hundred microseconds off the overall latency. Let me know if you need the exact gating bits for the other peripherals.