AVR high-end microcontroller internal EEPROM method! Can be used!

Publisher:YuexiangLatest update time:2019-11-23 Source: 51heiKeywords:AVR Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

/**************************************************************

;eeprom.c can be used in AVR microcontrollers, ATMEGA16 and ATMEGA8, under GCC

;Compiled. November 1, 2009! Chen Yongfei has tested it!

; Example of reading/writing atmega8515 internal EEPROM

;Write data 0....9 into eeprom, then read it out and display it with digital tube

***************************************************************/

#include

#include

#define uchar unsigned char

#define uint unsigned int

#define Hidden 16

fly DispTab[17]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E,0xFF};

float BitTab[6]={0x7F,0xBF,0xDF,0xEF,0xF7,0xFB};

uchar DispBuf[6]; //Display buffer

unsigned char Counter=0;

void io_init(void)

{

// Brings

PORT = 0xff;

DDRA = 0xff;

// PortB

PORTB = 0x0;

DDRB = 0x0;

// PortC

PORTC = 0xfc;

DDRC = 0xfc;

// PortD

PORTD = 0x0;

DDRD = 0x0;

}

void mDelay(uint DelayTime)

{

uint i;

for(;DelayTim>0;DelayTim--)

  for(i=0;i<600;i++)

  {;}

}

}

void disp()

flying i;

fly tmp;

if(++i>=6)

i=0;

PORTC=0xff; //Turn off the display

tmp=DispBuf[i];

PORTA=DispTab[tmp];

tmp=BitTab[i];

PORTC=tmp;

mDelay(1); //Delay 1ms

}

int main(void)

unsigned int Count=0;

unsigned char Addr=1; //Write numbers to address 1

uint8_t temp=0;

io_init();

DispBuf[0]=Hidden;

DispBuf[1]=Hidden;

DispBuf[2]=Hidden;

DispBuf[3]=Hidden;

DispBuf[4]=0; //The second lowest bit displays 0

while(1)

{

  temp=eeprom_read_byte (Addr);

  DispBuf[5]=temp;

  if(++Count==1000)

  { 

   Count=0;

   Counter++; 

   eeprom_write_byte(Addr,Counter);

  }

  if(Counter>=10)

  Counter=0; //The count value cycles between 0 and 9

  disp(); //Call the display program

}

}


Keywords:AVR Reference address:AVR high-end microcontroller internal EEPROM method! Can be used!

Previous article:AVR MCU PCF8591 conversion example source program operation library
Next article:AVR microcontroller GCC programming interrupt vector

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

ICC AVR font size adjustment
When using the ICCAVR C compiler, I felt that the default font size was uncomfortable to read and affected the code reading. After searching online, I found a way to change the font size: Tools -> Editor and Print options                                               Change the font size in Size and click OK.
[Microcontroller]
ICC AVR font size adjustment
AVR Thermometer DS18B20
#include mega48.h    #include delay.h    #include nokia3310.h   #include monobus.h    unsigned char data_H, data_L,wendu;   unsigned int  data_T;   void main(void)   {       LCD_init(); //LCD initialization              lcd_cls(); //Clear screen, cursor back to position      while(1)           {              monobus_i
[Microcontroller]
Design sharing of portable electrolyte analyzer based on XMEGA128
Electrolyte analyzers can measure the potassium (K), sodium (Na), chloride (Cl), calcium (Ca), pH value, etc. in biological specimens such as serum, plasma, whole blood and diluted urine, and provide standardized ion calcium (nCa) and total calcium (TCa) through calculation, which is of great clinical significance. Si
[Microcontroller]
Design sharing of portable electrolyte analyzer based on XMEGA128
D001-Development Tools-AVR Studio Environment Configuration and Usage Notes
Development environment: AVR Studio 4.19 + avr-toolchain-installer-3.4.1.1195-win32.win32.x86 1. Compile and connect classes 1-1. Use -Os level optimization (perform all optimizations without increasing code size): 2. Editing 2-1. Automatically save when exiting a project, and only display the file name of the fil
[Microcontroller]
D001-Development Tools-AVR Studio Environment Configuration and Usage Notes
AVR - Timer for external counting
The timer is used for external counting . The mega16 timer has an external clock source interface for external counting. Timer0 corresponds to T0 (PB0), and Timer1 corresponds to T1 (PB1). It can allow rising edge triggering and falling edge delay triggering, which are set by TCCRn. The principle of external c
[Microcontroller]
Using AVR microcontroller to drive RT1601 LCD display chip
After some research, I found out how to use ATmega 16 microcontroller to drive character LCD chips. Now I write down my research experience: The RT1601 LCD module I have uses the S6A0069 display chip. Here is a brief description of each pin: The control and data pins are configured as follows: -----------------------
[Microcontroller]
Using AVR microcontroller to drive RT1601 LCD display chip
AVR (Mega8) infrared receiver
Using the integrated infrared receiver, it can be decoded directly. Usually, the infrared receiver outputs a high level. When there is infrared data, it will have a corresponding level conversion according to the infrared data sent. You can find a remote control board at will, measure the infrared receiving waveform, a
[Microcontroller]
Design of Power Management System Based on AVR
0 Introduction Nowadays, due to its wide application in many fields such as civil and national defense, aerial robot technology has been increasingly valued by people and has attracted the attention of experts and scholars from various countries. The small rotor robot is based on a model helicopter and is equip
[Microcontroller]
Design of Power Management System Based on AVR
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号