simulavr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Simulavr-devel] [PATCH 05/13] Fix 16bit timer register handling bug


From: Onno Kortmann
Subject: [Simulavr-devel] [PATCH 05/13] Fix 16bit timer register handling bug
Date: Tue, 3 Mar 2009 23:46:05 +0100

There is a bug in the 16bit register handling (return before copying the
high-part makes no sense). Also, the 16 bit registers should be combined,
as according to at least some AVR datasheets, there is only one single shared
16bit temporary register on the chip.

Signed-off-by: Onno Kortmann <address@hidden>
---
 src/hwtimer.h |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/hwtimer.h b/src/hwtimer.h
index ff8cb0e..c8132eb 100644
--- a/src/hwtimer.h
+++ b/src/hwtimer.h
@@ -98,6 +98,11 @@ class HWTimer1 : public Hardware {
                unsigned char tccr1a;
                unsigned char tccr1b;
 
+               /* FIXME: According to the datasheets,
+                  there is only ONE temporary 16bit
+                  register in the AVR architecture. Combine all
+                  the various 16bit registers into one! */
+               
                unsigned short tcnt1;
                unsigned char tcnt1htemp;
 
@@ -164,13 +169,13 @@ class HWTimer1 : public Hardware {
                unsigned char GetTccr1b() { return tccr1b;}
 
                unsigned char GetTcnt1h() { return tcnt1htemp;}
-               unsigned char GetTcnt1l() { return tcnt1&0xff; 
tcnt1htemp=tcnt1>>8;}
+               unsigned char GetTcnt1l() { tcnt1htemp=tcnt1>>8; return 
tcnt1&0xff;}
                unsigned char GetOcr1ah() { return ocr1a>>8;}
                unsigned char GetOcr1al() { return ocr1a&0xff;}
                unsigned char GetOcr1bh() { return ocr1b>>8;}
                unsigned char GetOcr1bl() { return ocr1b&0xff;}
                unsigned char GetIcr1h() { return icr1htemp;}
-               unsigned char GetIcr1l() { return icr1&0xff; icr1htemp=icr1>>8;}
+               unsigned char GetIcr1l() { icr1htemp=icr1>>8; return icr1&0xff;}
 
                void SetTccr1a(unsigned char val);
                void SetTccr1b(unsigned char val); // { tccr1b=val;}
-- 
1.5.6.5






reply via email to

[Prev in Thread] Current Thread [Next in Thread]