8000 atmel-samd: Ensure MTB is off in case we ran a debug build before · sparkfun/circuitpython@c0159c5 · GitHub
[go: up one dir, main page]

Skip to content

Commit c0159c5

Browse files
committed
atmel-samd: Ensure MTB is off in case we ran a debug build before
a non-debug build.
1 parent 6baacf4 commit c0159c5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

atmel-samd/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,10 @@ safe_mode_t samd21_init(void) {
513513
REG_MTB_POSITION = ((uint32_t) (mtb - REG_MTB_BASE)) & 0xFFFFFFF8;
514514
REG_MTB_FLOW = (((uint32_t) mtb - REG_MTB_BASE) + TRACE_BUFFER_SIZE_BYTES) & 0xFFFFFFF8;
515515
REG_MTB_MASTER = 0x80000000 + (TRACE_BUFFER_MAGNITUDE_PACKETS - 1);
516+
#else
517+
// Triple check that the MTB is off. Switching between debug and non-debug
518+
// builds can leave it set over reset and wreak havok as a result.
519+
REG_MTB_MASTER = 0x00000000 + 6;
516520
#endif
517521

518522
// On power on start or external reset, set _ezero to the canary word. If it

0 commit comments

Comments
 (0)
0