Skip to content

Commit

Permalink
codal_port/ticks_cpu: Check CoreDebug DEMCR trace enable bit.
Browse files Browse the repository at this point in the history
The DAPLink controlled reset button performs a target reset via
SWD, and the CoreDebug trace enable  bit seems to be cleared
while the DWT->CTRL cycle count enable bit is not.

#179 (comment)
  • Loading branch information
microbit-carlos committed Apr 16, 2024
1 parent 8d9067d commit 90b9b7d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/codal_port/mphalport.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static inline void enable_irq(uint32_t state) {
}

static inline mp_uint_t mp_hal_ticks_cpu(void) {
if (!(DWT->CTRL & DWT_CTRL_CYCCNTENA_Msk)) {
if (!(DWT->CTRL & DWT_CTRL_CYCCNTENA_Msk) || !(CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk)) {
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
DWT->CYCCNT = 0;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
Expand Down

0 comments on commit 90b9b7d

Please sign in to comment.