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

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

Re: [avr-gcc-list] read write eeprom WINAVR20050214


From: andi
Subject: Re: [avr-gcc-list] read write eeprom WINAVR20050214
Date: Sat, 19 Feb 2005 09:05:40 +0700

Hi,

i declare variable in eeprom like this:

unsigned char Eeprom_Value __attribute__ ((section(".eeprom"))) = 30;

and when i read and write :
eeprom_read_byte((unsigned)&Eeprom_Value);
eeprom_write_byte((unsigned)&Eeprom_Value);

i got warning :

uart.c:2744: warning: passing arg 1 of `eeprom_write_byte' from incompatible
pointer type
uart.c:2758: warning: passing arg 1 of `eeprom_read_byte' from incompatible
pointer type

Where am I wrong ?
If I use WINAVR2004020 I got no warning like this .

Andi



----- Original Message -----
From: "E. Weddington" <address@hidden>
To: <address@hidden>
Cc: <address@hidden>
Sent: Friday, February 18, 2005 11:53 PM
Subject: Re: [avr-gcc-list] read write eeprom WINAVR20050214


> Eivind Sivertsen wrote:
>
> >>>The address is an address to an 8 bit variable (which is 16 bits on
> >>>AVR), not
> >>>a 8 bit address. Basic C pointer stuff.
> >>>
> >>>
> >>>
> >>----------------------------------------------
> >>Oh yes, you are right. silly me!
> >>
> >>--Royce.
> >>
> >>
> >
> >
> >- But the value to write is a  uint16_t ...? Look:
> >void eeprom_write_word (uint16_t *addr, uint16_t val)
> >
> >
> >
> >
> Hi Eivind,
>
> The functions in question are these:
>
> uint8_t     eeprom_read_byte (const uint8_t *addr)
> uint16_t     eeprom_read_word (const uint16_t *addr)
> void     eeprom_write_byte (uint8_t *addr, uint8_t val)
> void     eeprom_write_word (uint16_t *addr, uint16_t val)
>
> The question had to do with eeprom_read_byte(). There are a lot of
> people who seem to "freak out" when they see that "uint8_t" in the
> parameter listing, and they think: "Oh, no! I can only write to the
> first 256 bytes in eeprom!"
>
> But they don't look carefully enough to see that addr is a *pointer to
> an uint8_t*, and realize that a *pointer* is 16 bits. The pointer is
> pointing to a byte value, but the pointer itself can address up to 64K
> worth of memory.
>
> This is a typical C language newbie question. And we should probably put
> this in the avr-libc FAQ or something.....
>
> Eric
>
>
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
>





reply via email to

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