AVR 片内EEPROM问题

2019-03-24 21:00发布

#include<iom16v.h>
#include<macros.h>
#define uchar unsigned char
#define uint unsigned int
uchar unm[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar unm1[]={0x01,0x02,0x04,0x08};
uchar wei[]={0,0,0,0}; void init(void)
{
  DDRB=0XFF;
  DDRC=0X0F;
}
void xianshi(uchar a)
{
  uchar i;
  wei[3]=a/1000;
  wei[2]=a%1000/100;
  wei[1]=a%100/10;
  wei[0]=a%10;
  for(i=0;i<4;i++)
  {
    PORTB=unm[wei];
 PORTC=unm1;
  }
}
void EEPROM_write(uint a,uint b)
{
  SREG&=~BIT(7);
  while(EECR&BIT(EEWE));
  EEAR=a;
  EEDR=b;
  EECR|BIT(EEMWE);
  EECR|=BIT(EEWE);
  SREG|=BIT(7);
}
uchar EEPROM_read(uint c)
{
  uchar s;
  SREG&=~BIT(7);
  while(EECR&BIT(EEWE));
  EEAR=c;
  EECR|=BIT(EERE);
  s=EEDR;
  return s;
}
void main(void)
{
  uchar e;
  init();
  e=EEPROM_read(2);
  e++;
  EEPROM_write(2,e);
  while(1)
  {
    xianshi(e);
  }
 
}
  为什么无反应?求教 [ 本帖最后由 wgla5883792 于 2011-8-4 22:12 编辑 ] 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
2条回答
keyearth
2019-03-25 02:32
 精彩回答 2  元偷偷看……0人看过

一周热门 更多>