void EEPROM_write(unsigned int uiAddress, unsigned char ucData) { /* 等待上一次寫操作結(jié)束 */ while(EECR & (1<<EEWE)) ; /* 設(shè)置地址和數(shù)據(jù)寄存器*/ EEAR = uiAddress; EEDR = ucData; /* 置位EEMWE */ EECR |= (1<<EEMWE); /* 置位EEWE 以啟動寫操作*/ EECR |= (1<<EEWE); } unsigned char EEPROM_read(unsigned int uiAddress) { /* 等待上一次寫操作結(jié)束 */ while(EECR & (1<<EEWE)) ; /* 設(shè)置地址寄存器*/ EEAR = uiAddress; /* 設(shè)置EERE 以啟動讀操作*/ EECR |= (1<<EERE); /* 自數(shù)據(jù)寄存器返回數(shù)據(jù) */ return EEDR; } void EEPROM_read_block(unsigned char *store_point, unsigned int _uiAddress,unsigned char n) { unsigned char i; //unsigned int x1; //unsigned char x2; for(i=0;i<n;i++) { //x2=EEPROM_read(_uiAddress); //_uiAddress++; //x1=EEPROM_read(_uiAddress); //x1<<8; //x1=x1+x2; //* store_point=x1; * store_point=EEPROM_read(_uiAddress); store_point++; _uiAddress++; } }
|