From 81615ad9d53aef5583e064f340e9cdeb23d4119c Mon Sep 17 00:00:00 2001 From: Robbe Derks Date: Thu, 22 Jan 2026 13:46:26 +0100 Subject: [PATCH] Align delay and compensate (#2318) * align delay and compensate * empty --- board/libc.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/board/libc.h b/board/libc.h index c5f02193..c5ea629f 100644 --- a/board/libc.h +++ b/board/libc.h @@ -1,8 +1,10 @@ // **** libc **** -void delay(uint32_t a) { +__attribute__((aligned(32), noinline)) void delay(uint32_t a) { + // loop is 2.6x faster when 32-byte aligned (ART accelerator prefetches flash in 32-byte chunks) volatile uint32_t i; - for (i = 0; i < a; i++); + uint32_t n = a * 13U / 5U; + for (i = 0; i < n; i++) {} } void assert_fatal(bool condition, const char *msg) {