首页 > 代码库 > ATmega128A-AU EEPROM的读写
ATmega128A-AU EEPROM的读写
#include <iom128a.h>#include "intrinsics.h"// write one byte data to pointed EEPROM addressvoid pdd_write_eeprom_byte(u16 uiAddress, u8 ucData){ char cSREG; // store SREG value cSREG = SREG; // disable global interrupt __disable_interrupt(); // Wait for completion of previous write while (EECR & (1 << EEWE)) { ; } // Set up address and data registers EEAR = uiAddress; EEDR = ucData; // Write logical one to EEMWE EECR |= (1<<EEMWE); // Start eeprom write by setting EEWE EECR |= (1<<EEWE); // restore SREG value SREG = cSREG;}// read one byte data from pointed EEPROM addressu8 pdd_read_eeprom_byte(u16 uiAddress){ char cSREG; // store SREG value cSREG = SREG; __disable_interrupt(); // Wait for completion of previous write while (EECR & (1 << EEWE)) { ; } // Set up address register EEAR = uiAddress; // Start eeprom read by writing EERE EECR |= (1 << EERE); // restore SREG value SREG = cSREG; // Return data from data register return EEDR;}
ATmega128A-AU EEPROM的读写
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。