summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-03-10 14:58:26 +1100
committerDamien George <damien.p.george@gmail.com>2017-03-10 14:58:26 +1100
commit4351d16e62183720464dc9b7c910b87a36aa270b (patch)
tree226096fa9e6e48b0eefac954764af4ea4ff9aa4c
parentc9705cff6860c9d77ea009ce6a6c0e9e946a0b21 (diff)
stmhal/mphalport: Get ticks_cpu() working on F7 MCUs.
-rw-r--r--stmhal/mphalport.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/stmhal/mphalport.c b/stmhal/mphalport.c
index 64c1164cc..dff781ff2 100644
--- a/stmhal/mphalport.c
+++ b/stmhal/mphalport.c
@@ -72,6 +72,10 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
void mp_hal_ticks_cpu_enable(void) {
if (!mp_hal_ticks_cpu_enabled) {
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
+ #if defined(__CORTEX_M) && __CORTEX_M == 7
+ // on Cortex-M7 we must unlock the DWT before writing to its registers
+ DWT->LAR = 0xc5acce55;
+ #endif
DWT->CYCCNT = 0;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
mp_hal_ticks_cpu_enabled = true;