From 022c7435a63087823003e483d9bcf501ed4f3f9e Mon Sep 17 00:00:00 2001 From: geijoenr Date: Fri, 2 Jan 2015 13:05:17 +0100 Subject: [PATCH] timer: reverse order of assigment in set_timer_duration sdcc picks up wrong 'duration' from the stack if done the other way around --- Kernel/timer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Kernel/timer.c b/Kernel/timer.c index d97ec406..c4059aa5 100644 --- a/Kernel/timer.c +++ b/Kernel/timer.c @@ -16,8 +16,10 @@ timer_t set_timer_duration(uint16_t duration) } /* obvious code is return (miniticks+duration), however we have to do */ /* it this longwinded way or sdcc doesn't load miniticks atomically */ - a = ticks.h.low; - a += duration; + /* sdcc bug: ordering affects result */ + a = duration; + a += ticks.h.low; + return a; } -- 2.34.1