Why eeprom_read_byte/eeprom_write_byte use uint8_t type addr

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In WINAVR include file, eeprom function defined like bellow:

extern uint8_t eeprom_read_byte (const uint8_t *addr);
^^^^^
extern uint16_t eeprom_read_word (const uint16_t *addr);
^^^^^
extern void eeprom_write_byte (uint8_t *addr, uint8_t val);
^^^^^
extern void eeprom_write_word (uint16_t *addr, uint16_t val);
^^^^^
The questions are:
1) Why using 8bit addres while read or write a bye?
2) Can I just read or write ONE byte using 16 bit address? How can I do it?

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The size of a address (i.e. pointer in C) is always the address size of the particular processor architecture. That is 16 bits with an AVR.

uint8_t *addr means that the pointer points to an 8 bit variable, not that it is an 8 bit address.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you, Julius

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Removed spam.

Last Edited: Thu. Oct 29, 2015 - 06:55 AM