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

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

Re: [avr-gcc-list] eeprom usage - Measuring duration of function calls


From: Brett Abbott
Subject: Re: [avr-gcc-list] eeprom usage - Measuring duration of function calls
Date: Fri, 01 Nov 2002 09:16:17 +1300
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1

Hi

An easy way to measure the duration/length of a function call is to use AVR Studio.  Set the clock speed correctly and then, using the View->Processor window combined with appropriately placed breakpoints, you can use the Stopwatch and cycle counter to measure length.

There are a few limitations with the implementation of some eeprom and SPM type delays etc but unless you're doing significant eeprom work, this usually gives a reliable indication of runtimes.

Hope this helps.

Cheers
Brett

Jamie Morken wrote:
Hi David,


As you can see from the code below, extracted from eeprom.s, the first
check is to see if the eeprom is ready, so your code is safe.
.global _U(eeprom_wb)

Does that code stall if the eeprom isn't ready? I still haven't learned
much assembler unfortunately (or was that fortunately?)

I am looking for good way to measure how many clocks a given function call
or subroutine will take given AVR code.
Does anyone know of a decent method to do this? I know AVR is supposedly
1MIPS/MHz but with calls to asin(x) etc.
it seems hard to estimate.

cheers,
Jamie Morken

_U(eeprom_wb):
sbic EECR, EEWE
rjmp _U(eeprom_wb) /* make sure EEPROM is ready */
#ifdef EEARH
out EEARH, addr_hi
#endif
out EEARL, addr_lo
out EEDR, val
in __tmp_reg__, SREG
cli ; /* no ints between setting EEMWE and EEWE */
sbi EECR, EEMWE
sbi EECR, EEWE
out SREG, __tmp_reg__
ret
#undef val
#endif /* L_eeprom_wb */

The 323 data sheet gives details of EECR and EEWE.

David Breeze


Jamie Morken <address@hidden> 30 October 2002 23:59:10 >>>
Hi,

I read the datasheet for the AVR I am using (atmega323)
and it gave an eeprom write time of 3.8ms (MAX)
I tested the below code out and it works fine.
Is a delay built into the read/write functions or am I just pushing the
limits of the eeprom? Is this safe? I already wrote out the code to
read/write 16 byte messages to eeprom one byte every 5ms
(ironically that code doesn't work but the below does)

cheers,
Jamie Morken

eeprom_wb(0, 123);
eeprom_wb(1, 124);
eeprom_wb(2, 125);
eeprom_wb(3, 126);
eeprom_wb(4, 127);
eeprom_wb(5, 128);
eeprom_wb(6, 129);
eeprom_wb(7, 130);

printf("eeprom0 = %i\r", eeprom_rb(0));
printf("eeprom1 = %i\r", eeprom_rb(1));
printf("eeprom2 = %i\r", eeprom_rb(2));
printf("eeprom3 = %i\r", eeprom_rb(3));
printf("eeprom4 = %i\r", eeprom_rb(4));
printf("eeprom5 = %i\r", eeprom_rb(5 ));
printf("eeprom6 = %i\r", eeprom_rb(6));
printf("eeprom7 = %i\r", eeprom_rb(7));




avr-gcc-list at http://avr1.org

This e-mail is intended only for the person(s)
to whom it is addressed.
If an addressing or transmission error has misdirected
this e-mail,
please notify the author by replying to this e-mail.

If you are not the intended recipient
you must not use, disclose, copy, print
or rely on this e-mail.

Joy Mining Machinery Ltd may monitor
outgoing and incoming e-mails and other telecommunications
on its e-mail and telecommunication systems.


avr-gcc-list at http://avr1.org


-- 
-----------------------------------------------------------------
Brett Abbott, Managing Director, Digital Telemetry Limited
Email: address@hidden
PO Box 24 036 Manners Street, Wellington, New Zealand
Phone +64 (4) 5666-860  Mobile +64 (21) 656-144
------------------- Commercial in confidence --------------------


reply via email to

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