Skip to content

Commit 5d8afa2

Browse files
mikesmittydeadprogram
authored andcommitted
fix(rp2): disable DBGPAUSE on startup
1 parent 0dca016 commit 5d8afa2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/machine/machine_rp2.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ func machineInit() {
5858

5959
// Peripheral clocks should now all be running
6060
unresetBlockWait(RESETS_RESET_Msk)
61+
62+
// DBGPAUSE pauses the timer when a debugger is connected. This prevents
63+
// sleep functions from ever returning, so disable it.
64+
timer.setDbgPause(false)
6165
}
6266

6367
//go:linkname ticks runtime.machineTicks

src/machine/machine_rp2_timer.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,15 @@ func (tmr *timerType) lightSleep(us uint64) {
101101
// Disable interrupt
102102
intr.Disable()
103103
}
104+
105+
// setDbgPause sets whether this timer is paused when a debugger is connected.
106+
func (tmr *timerType) setDbgPause(enable bool) {
107+
const bitPos = 1
108+
const bitMask = 0b11
109+
val := uint32(0b00)
110+
if enable {
111+
// Disable timer when debugger is connected to either core.
112+
val = 0b11
113+
}
114+
tmr.dbgPause.ReplaceBits(val, bitMask, bitPos)
115+
}

0 commit comments

Comments
 (0)