AVR128 program - EEPROM records reset times

Publisher:Yuexiang888Latest update time:2016-03-04 Source: eefocusKeywords:AVR128 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
#include
#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);
float TempData[8];
uchar WeiMa[8] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
uchar led_discode[11]={0xc0,0xf9,0xa4,0xb0,0x99,
                       0x92,0x82,0xf8,0x80,0x90,0xff};      
 
void main(void)
{
flying i;
Mcu_IO_Init();
i=EEPROM_read(1);
i++;
EEPROM_write(1,i);
TempData[2] = led_discode[i/100];   
TempData[1] = led_discode[i];    
    TempData[0] = led_discode[i/10];    
    while(1)
{
display(6,2);  
}
}
 
void Mcu_IO_Init(void)
{
DDRA=0XFF;
PORT=0XFF;
DDRC=0XFF;                   
PORTC=0XFF;
 
DDRF|=0X0E;
PORTF|=0X0E;
PORTF&=0xF7;             
 
DDRB |=0X10;          
PORTB|=0X10;  
}
 
void EEPROM_write(uint EEPROM_ADDR, uchar EEPROM_DAT)
{
  CLI();
     while(EECR & (1<
EEARH = 0X00;
EEARL = EEPROM_ADDR;
EEDR = EEPROM_DAT; 
EECR |= (1<
EECR |= (1<
BE();
}
 
uchar EEPROM_read(uint EEPROM_ADDR)
{
 CLI();
     while(EECR & (1<
EEARH = 0X00;
EEARL = EEPROM_ADDR; 
EECR |= (1<
return EEDR;
BE();
 
 
void display(uchar FirstBit,uchar Num)
{
    unsigned char i;  
for(i=0;i  
{
PORTC=led_discode[10];                       
   PORTA=WeiMa[i+FirstBit];       
   PORTC=TempData[i];                     
Delayms(5);    
}   
}
void Delayms(uint MS)  
{
     uint i,j;
     for( i=0;i
     for(j=0;j<1141;j++);
}
Keywords:AVR128 Reference address:AVR128 program - EEPROM records reset times

Previous article:AVR128 Program - DS1302 Clock Chip
Next article:AVR128 program - stepper motor forward and reverse control

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号