Skip to content

Commit 90b9b7d

Browse files
codal_port/ticks_cpu: Check CoreDebug DEMCR trace enable bit.
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)
1 parent 8d9067d commit 90b9b7d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/codal_port/mphalport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static inline void enable_irq(uint32_t state) {
4646
}
4747

4848
static inline mp_uint_t mp_hal_ticks_cpu(void) {
49-
if (!(DWT->CTRL & DWT_CTRL_CYCCNTENA_Msk)) {
49+
if (!(DWT->CTRL & DWT_CTRL_CYCCNTENA_Msk) || !(CoreDebug->DEMCR & CoreDebug_DEMCR_TRCENA_Msk)) {
5050
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
5151
DWT->CYCCNT = 0;
5252
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;

0 commit comments

Comments
 (0)