Skip to content

Commit 4351d16

Browse files
committed
stmhal/mphalport: Get ticks_cpu() working on F7 MCUs.
1 parent c9705cf commit 4351d16

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

stmhal/mphalport.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
7272
void mp_hal_ticks_cpu_enable(void) {
7373
if (!mp_hal_ticks_cpu_enabled) {
7474
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
75+
#if defined(__CORTEX_M) && __CORTEX_M == 7
76+
// on Cortex-M7 we must unlock the DWT before writing to its registers
77+
DWT->LAR = 0xc5acce55;
78+
#endif
7579
DWT->CYCCNT = 0;
7680
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
7781
mp_hal_ticks_cpu_enabled = true;

0 commit comments

Comments
 (0)