avr-gcc-list
[Top][All Lists]
Advanced

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

[avr-gcc-list] Strange thing...


From: John Yannakopoulos
Subject: [avr-gcc-list] Strange thing...
Date: Mon, 22 Sep 2003 16:15:08 +0300 (EET DST)

Hi all.

I'm trying to measure the execution time (in CPU cycles) of a simple for
loop. For my settings refer to the PS section of my e-mail. Imagine the
following situ:

unsigned short value = 62;
unsigned short i;

start_timer();
for (i = 0; i < value; i++) ;
stop_timer();

The loop in AVR assembly, is shown below:

mov ...
mov ...

loop:
        adiw ...
        cpi  ...
        cpc  ...
        brlo loop

When 'value' equals to 62, I get a time value of 190 cycles. When I
set 'value' to 64, the time measured is 16 cycles! What am I doing wrong?

Regards,

--
Ioannis Yannakopoulos.

PS> My settings are: ATMEL AVR 8535 (i.e. approx. 4MHz CPU clock), 'avr-gcc'
on a linux machine, 'uisp' for mC programming. I'm using the timer 0 of
the mC (without prescaling) and I'm counting overflows + remainder clock
ticks (in interrupt mode). Thus, the final time measurement is as follows:
Time = (overflows << 8) + remainder.



reply via email to

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