From 02168c8615b38b24030018b8e678fde18f391228 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Wed, 21 Feb 2024 14:50:06 +0100 Subject: stm32f7: slightly un-break delay_us and delay_ms --- src/arch/stm32f746zg-nucleo/arch.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/arch/stm32f746zg-nucleo/arch.cc b/src/arch/stm32f746zg-nucleo/arch.cc index 443a2cf..5f9b53b 100644 --- a/src/arch/stm32f746zg-nucleo/arch.cc +++ b/src/arch/stm32f746zg-nucleo/arch.cc @@ -64,19 +64,21 @@ extern void loop(); volatile char run_loop = 0; #endif -// for 216 MHz(?) +static volatile int delay_counter; +// horribly broken void Arch::delay_us(unsigned int const us) { - volatile int x = us * 145; - while (x--) { + delay_counter = us * 37; + while (delay_counter--) { __asm("nop"); } } +// horribly broken void Arch::delay_ms(unsigned int const ms) { for (unsigned int i = 0; i < ms; i++) { - volatile int x = 143990; - while (x--) { + delay_counter = 36364; + while (delay_counter--) { __asm("nop"); } } -- cgit v1.2.3