Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/machine/machine_rp2.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func machineInit() {

// Peripheral clocks should now all be running
unresetBlockWait(RESETS_RESET_Msk)

// DBGPAUSE pauses the timer when a debugger is connected. This prevents
// sleep functions from ever returning, so disable it.
timer.setDbgPause(false)
}

//go:linkname ticks runtime.machineTicks
Expand Down
12 changes: 12 additions & 0 deletions src/machine/machine_rp2_timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,15 @@ func (tmr *timerType) lightSleep(us uint64) {
// Disable interrupt
intr.Disable()
}

// setDbgPause sets whether this timer is paused when a debugger is connected.
func (tmr *timerType) setDbgPause(enable bool) {
const bitPos = 1
const bitMask = 0b11
val := uint32(0b00)
if enable {
// Disable timer when debugger is connected to either core.
val = 0b11
}
tmr.dbgPause.ReplaceBits(val, bitMask, bitPos)
}