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


From: Jamie Morken
Subject: Re: [avr-gcc-list] eeprom usage
Date: Thu, 31 Oct 2002 00:34:42 -0800

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



reply via email to

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