|
楼主 |
发表于 2007-5-16 03:01:23
|
显示全部楼层
目前确认7.13版存在EEPROM编译错误(针对M48/88/168系列)
解决方案如下:
去掉程序中
# include <eeprom.h>
将如下的代码粘贴进程序:
#define EEPROM_READ(addr, dst) EEPROMReadBytes(addr, &dst, sizeof (dst))
#define EEPROM_WRITE(addr, src) EEPROMWriteBytes(addr, &src, sizeof (src))
int EEPROMwrite( int location, unsigned char byte)
{
unsigned char oldSREG;
EEAR = location;
EEDR = byte;
oldSREG = SREG;
SREG &= ~0x80; // disable interrupt
EECR |= 0x04; // Set MASTER WRITE enable
EECR |= 0x02; // Set WRITE strobe
while (EECR & 0x02); // Wait until write is done
SREG = oldSREG;
return 0; // return Success.
// Could be expanded so that
// the routine checks that the address
// is within the range of the chip.
}
unsigned char EEPROMread( int location)
{
EEAR = location;
EECR |= 0x01; // Set READ strobe
return (EEDR); // Return byte
}
void EEPROMReadBytes(int addr, void *ptr, int size)
{
char *dst = ptr;
while (size--)
{
*dst = EEPROMread(addr);
addr++;
dst++;
}
}
void EEPROMWriteBytes(int addr, void *ptr, int size)
{
char *src = ptr;
while (size--)
{
EEPROMwrite(addr, *src);
addr++;
src++;
}
}
-----------------------------------------------
由此,其他牵涉到EEPROM的操作都照旧,不需要任何修改。 |
|