ATmega8535L Eeprom Example Program

Publisher:CelestialLightLatest update time:2017-12-13 Source: eefocusKeywords:ATmega8535L  Eeprom Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

ATmega8535L Eeprom Example Program

//***************ICCAVR V6.30 compiled*****************// 

#include                 

#define uchar unsigned char 
#define uint unsigned int 

//digital tube font table, corresponding to 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F // 
uchar Table[16]={0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 
                 0x7f, 0x6f, 0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71}; 
uchar Read_Data[4]; //define read data 

void DelayMs(uint i) //Ms level delay, parameter i is the delay time 
{uint j; 
 for(;i!=0;i--) 
  {for(j=8000;j!=0;j--) {;}} } 
void 

Display(uchar *p) //Dynamic display function, parameter p is the name of the array to be displayed 
{uchar i,sel=0x01;            
 for(i=0;i<4;i++) 
  {PORTA=sel; //Select the rightmost digital tubePORTC 
   =0xff-Table[p[i]]; //Send font code 
   DelayMs(1); //Display delay     
   sel=sel<<1; //Shift to display the previous bit 
  } 


void Init_IO(void) //Initialize I/O port 
{DDRA=0xff; //Set port A to push-pull 1 output 
 PORTA=0xff; 
 DDRC=0xff; //Set port C to push-pull 1 output              
 PORTC=0xff; 


void Write_EEPROM(uchar Data,uint Address) 
{if(EECR&0x20) DelayMs(4); 
 EEARH=Address>>8; 
 EEARL=Address&0x00ff; 
 EEDR=Data; 
 EECR=EECR|0x04; 
 EECR=EECR|0x02; 
 DelayMs(4); 


uchar Read_EEPROM(uint Address) 
{uchar i; 
 if(EECR&0x01) DelayMs(4); 
 EEARH=Address>>8; 
 EEARL=Address&0x00ff; 
 EECR=EECR|0x01; 
 DelayMs(5); 
 i=EEDR; 
 return(i); 


void main(void) 
{uchar i; 
 Init_IO(); //Initialize I/O port 
 PORTA=0xff; //Light up to test all digital tubes 
 PORTC=0x00;    
 DelayMs(300); //Delay 
 PORTC=0xff; //Turn off all digital tubes 
 for(i=0;i<4;i++) 
    Write_EEPROM(5*i,i); 
 for(i=0;i<4;i++) 
    Read_Data[i]=Read_EEPROM(i); 
 while(1) 
 Display(Read_Data); 


Keywords:ATmega8535L  Eeprom Reference address:ATmega8535L Eeprom Example Program

Previous article:ATmega8535L Marquee Program (ICC Compiler)
Next article:atmega8535 Ad conversion c program

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号