Skip to content
Snippets Groups Projects
Commit 6544a40b authored by Roberto Hexsel's avatar Roberto Hexsel
Browse files

fixed extCounter.c

parent 293c22b3
No related branches found
No related tags found
No related merge requests found
...@@ -11,15 +11,16 @@ ...@@ -11,15 +11,16 @@
#define CNT_VALUE 0x40000040 // set count to 64 cycles #define CNT_VALUE 0x40000040 // set count to 64 cycles
void main(void) { void main(void) {
int i, increased, new, old; int i, increased, new, old, newValue;
newValue = CNT_VALUE;
startCounter(CNT_VALUE, 0); // no interrupts startCounter(newValue, 0); // no interrupts
for (i=0; i < N; i++) { // repeat N rounds for (i=0; i < N; i++) { // repeat N rounds
print(i); // print number of round 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; increased = TRUE;
old = 0; old = 0;
...@@ -29,11 +30,13 @@ void main(void) { ...@@ -29,11 +30,13 @@ void main(void) {
if ( (new=readCounter()) > old) { if ( (new=readCounter()) > old) {
increased = increased & TRUE; increased = increased & TRUE;
old = new; old = new;
print(new); // print current count
} else { } else {
increased = FALSE; increased = FALSE;
} }
} while ( (readCounter() & 0x3fffffff) < (CNT_VALUE & 0x3ffffff) ); // done? } while ( (readCounter() & 0x3fffffff) < (newValue & 0x3ffffff) );
// are we done yet?
if (increased) { if (increased) {
to_stdout('o'); to_stdout('o');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment