#include<iom16v.h>
#include<macros.h>
#define uchar unsigned char
#define uint unsigned int
void init()
{
DDRA=0xff;
PORTA=0xff;
}
void delay (uint z)
{
uchar x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void eeprom_write(uint addr,uchar dat)
{
SREG&=BIT(7);//关总中断
while(EECR&BIT(EEWE));//等待EEPROM为0
//下一行 illegal character ` 243'
// illegal character ` 273'
EEAR=addr;
//下一行 found `unsigned int' expected a function
//operands of = have illegal types `void' and `unsigned char'
//lvalue required
EEDR=dat;
EECR|=BIT(EEMWE);
EECR|=BIT(EEWE);
SREG|=BIT(7);
}
uchar eeprom_read(uint addr)
{
uchar edata;
SREG&=BIT(7);//关总中断
while(EECR&BIT(EEWE));
EEAR=addr;
EECR|=BIT(EERE);
edata=EEDR;
SREG|=BIT(7);
return edata;
}
void main()
{
uchar i=10;
init();
i=eeprom_read(2);
i++;
eeprom_write(2,i);
while(1)
{
PORTA=eeprom_read(2);
delay(500);
}
}
iccavr编译器,有两个地方出错在代码//下一行中对应的错误。求前辈指导!
此帖出自
小平头技术问答
一周热门 更多>