From 6544a40b9aa5ec8ae38fcf867d19f9a51091d84c Mon Sep 17 00:00:00 2001 From: Roberto Hexsel <roberto@inf.ufpr.br> Date: Thu, 7 May 2015 15:41:49 -0300 Subject: [PATCH] fixed extCounter.c --- cMIPS/tests/extCounter.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cMIPS/tests/extCounter.c b/cMIPS/tests/extCounter.c index 51ac316..90400bd 100644 --- a/cMIPS/tests/extCounter.c +++ b/cMIPS/tests/extCounter.c @@ -11,15 +11,16 @@ #define CNT_VALUE 0x40000040 // set count to 64 cycles void main(void) { - int i, increased, new, old; + int i, increased, new, old, newValue; - - startCounter(CNT_VALUE, 0); // no interrupts + newValue = CNT_VALUE; + startCounter(newValue, 0); // no interrupts for (i=0; i < N; i++) { // repeat N rounds print(i); // print number of round - startCounter((CNT_VALUE + (i<<2)), 0); // num cycles increases with i + newValue = CNT_VALUE + (i<<3); + startCounter(newValue, 0); // num cycles increases with i increased = TRUE; old = 0; @@ -29,11 +30,13 @@ void main(void) { if ( (new=readCounter()) > old) { increased = increased & TRUE; old = new; + print(new); // print current count } else { increased = FALSE; } - } while ( (readCounter() & 0x3fffffff) < (CNT_VALUE & 0x3ffffff) ); // done? + } while ( (readCounter() & 0x3fffffff) < (newValue & 0x3ffffff) ); + // are we done yet? if (increased) { to_stdout('o'); -- GitLab