AVR128的程序——EEPROM記錄復位次數(shù)
#include
#define uchar unsigned char
#define uint unsigned int
void EEPROM_write(uint EEPROM_ADDR, uchar EEPROM_DAT);
void Delayms(uint MS);
void display(uchar FirstBit,uchar Num);
void Mcu_IO_Init(void);
uchar EEPROM_read(uint EEPROM_ADDR);
uchar TempData[8];
uchar WeiMa[8] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
uchar led_discode[11]={0xc0,0xf9,0xa4,0xb0,0x99,
void main(void)
{
uchar i;
Mcu_IO_Init();
i=EEPROM_read(1);
i++;
EEPROM_write(1,i);
TempData[2] = led_discode[i/100];
TempData[1] = led_discode[i];
{
display(6,2);
}
}
void Mcu_IO_Init(void)
{
DDRA=0XFF;
PORTA=0XFF;
DDRC=0XFF;
PORTC=0XFF;
DDRF|=0X0E;
PORTF|=0X0E;
PORTF&=0xF7;
DDRB |=0X10;
PORTB|=0X10;
}
void EEPROM_write(uint EEPROM_ADDR, uchar EEPROM_DAT)
{
EEARH = 0X00;
EEARL = EEPROM_ADDR;
EEDR = EEPROM_DAT;
EECR |= (1<
EECR |= (1< CLI(); while(EECR & (1< unsigned char i; PORTA=WeiMa[i+FirstBit]; PORTC=TempData[i]; uint i,j; for( i=0;i for(j=0;j<1141;j++);
SEI();
}
uchar EEPROM_read(uint EEPROM_ADDR)
{
EEARH = 0X00;
EEARL = EEPROM_ADDR;
EECR |= (1<
return EEDR;
SEI();
}
void display(uchar FirstBit,uchar Num)
{
for(i=0;i
{
PORTC=led_discode[10];
Delayms(5);
}
}
void Delayms(uint MS)
{
}
關(guān)鍵詞:
AVR128EEPROM復位次
評論