uint8_t testBuffer[EEPROM_PAGESIZE] = {"Accessing Atmel AVR XMEGA EEPROM"};
int main(void)
{
uint8_t dat;
Usart_Init();
EEPROM_FlushBuffer(); //Flush buffer just to be sure when we start.
EEPROM_DisableMapping(); //Write and read two bytes using IO-mapped access.
EEPROM_WriteByte(0x03,0x01,0x52); //Write bytes.
EEPROM_WriteByte(0x03,0x02,0x07);
dat=EEPROM_ReadByte(0x03,0x01);
Usart_PutChar(dat); //Sent bytes.
dat=EEPROM_ReadByte(0x03,0x02); //Read bytes.
Usart_PutChar(dat);
/* Load, erase and write. */
EEPROM_LoadPage(testBuffer);
EEPROM_ErasePage(0x01);
EEPROM_SplitWritePage(0x01);
/* Read back and check. */
for (uint8_t i = 0; i < EEPROM_PAGESIZE; ++i)
{
dat=EEPROM_ReadByte(0x01,i);
Usart_PutChar(dat);
}
while(1);
}
主函数,其他程序,参考avr1315上即可 |