pp.421ff.
#include <avr/io.h> #include <avr/eeprom.h> #include "USART.h" int main(){ initUSART(); eeprom_update_byte((uint8_t *)0, 9); // [0]番地に0d9を書き込む。 eeprom_update_word((uint16_t *)1, 0xabcd); // [1]~[2]番地に0xabcdを書き込む。 char str[] = "The work of telegraph offices, especially those using undersea cables, had not yet settled into a smooth routine."; eeprom_update_block(str, (char *)3, sizeof str); // [3]番地~に文字列(排列)を書き込む。 /********************************************************************************************/ uint8_t a = eeprom_read_byte((uint8_t *)0); // [0]番地から1バイトを読み出す。 printByte(a); printString("\n"); uint16_t b = eeprom_read_word((uint16_t *)1); // [1]番地から2バイトを読み出す。 printHexWord(b); printString("\n"); char strP[50]; eeprom_read_block(strP, (char *)3, 20); // [3]番地から20バイトを読み出してAVRの&strP[0]番地に格納する。 printString(strP); printString("\n"); return 0; }