AVR128的程序——EEPROM记录复位次数
#include
#define uchar unsigned char
#define uint
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 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) { }
AVR128EEPROM复位次 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)