AVR EEPROM Read and Write

Publisher:创意旋律Latest update time:2016-08-15 Source: eefocusKeywords:AVR Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
void Write_byte_eeprom(unsigned short address,unsigned char data)

{
    while (EECR&(1<  EEAR = address;
 EEDR = data;
 EECR |= (1<  EECR |= (1< }

unsigned char Read_byte_eeprom(unsigned short address)
{
    while (EECR&(1<  EEAR = address;
 EECR |= (1<  
 return EEDR;
}

 

void Refresh_eeprom(void)
{
    unsigned char i = 0;
 unsigned char check = 0;
 unsigned char *p = (unsigned char *)&ram;
 
 asm("cli");
 
 ram.start = 0x55;
 for (; i<(sizeof(ram)-1); i++)
 {
     Write_byte_eeprom(i,*(p+i));
  check += *(p+i);
 }
 Write_byte_eeprom(i,check);
 
 asm("sei"); 
}

void Read_eeprom(void)
{
    unsigned char i = 0;
    unsigned char check = 0;
 unsigned char *p = (unsigned char *)&ram;
 
 for (; i<(sizeof(ram)-1); i++)
 {
     *(p+i) = Read_byte_eeprom(i);
  check += *(p+i);
 }
 *(p+i) = Read_byte_eeprom(i);
 //取值合理性判断
 

 if ((*(p+i) != check) || (*p != 0x55))
 {
     Parameter_reset();
 }

}

Keywords:AVR Reference address:AVR EEPROM Read and Write

Previous article:ARM-LINUX key interrupt driver
Next article:ATMEGA16 multi-channel AD acquisition

Recommended ReadingLatest update time:2024-11-16 14:26

Multi-protocol RFID reader based on AVR microcontroller and EM4094 reader/writer chip
  introduction   Radio frequency identification (RFID) is an emerging technology that uses wireless methods to identify electronic data carriers (electronic tags). Compared with contact IC cards and barcode recognition systems, it has huge advantages. The use of radio frequency identification technology can effectiv
[Microcontroller]
Multi-protocol RFID reader based on AVR microcontroller and EM4094 reader/writer chip
AVR MCU Tutorial - UART Advanced
In the first issue, we have started to use UART to realize the communication between the microcontroller development board and the computer, but we only briefly talked about some concepts and the use of library functions. In this tutorial, we will have a deeper understanding of UART from various aspects such as hardwa
[Microcontroller]
AVR MCU Tutorial - UART Advanced
What is the programming method for avr microcontroller?
  This section will introduce the popular programming methods of AVR microcontrollers in detail and briefly describe their working principles, aiming to allow AVR enthusiasts to choose or make appropriate programming tools according to their needs.   1. What programming method is used for AVR microcontroller?   AVR mi
[Microcontroller]
What is the programming method for avr microcontroller?
Features, advantages and functions of AVR microcontrollers
High reliability, powerful functionality, high speed, low power consumption and low price have always been important indicators for measuring the performance of microcontrollers, and are also necessary conditions for microcontrollers to occupy the market and survive. The early single-chip microcomputers adopted a sa
[Microcontroller]
Features, advantages and functions of AVR microcontrollers
The specific application of AVR microcontroller in life
    This article discusses the specific applications of single-chip microcomputers in life, tells the development history and characteristics of single-chip microcomputers, and looks forward to the prospects of single-chip microcomputers.     With the continuous development of urban public transportation, unmanned tic
[Microcontroller]
Terminal display and control design based on AVR microcontroller
1 Introduction With the rapid development of the information industry, LCD devices, as one of the information display terminals, have also achieved unprecedented development. Liquid crystal displays (LCDs) have many advantages that many other displays cannot match, such as rich display information, low power co
[Power Management]
Terminal display and control design based on AVR microcontroller
AVR microcontroller serial port operation program
#include #include #include #include #include     #define FOSC 8000000 //MCU working clock frequency     typedef unsigned int uint16; typedef unsigned char uchar8;     uchar8 DoubleIRData ={0x64,0x00,0x20,0x04,0x40,0x00,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; //Dual infrared emission data takes
[Microcontroller]
Comparative Analysis of AVR, 51 Series, and PIC Microcontrollers
The single-chip microcomputer was born in the late 1970s. It refers to a complete computer system integrated on a chip. It includes CPU, memory, internal and external bus systems. Among AVR, 51 series, and PIC single-chip microcomputers, the 51 series is the most basic, and it also has disadvantages such as easy dec
[Microcontroller]
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号