/**************************************************************
;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 } }
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
- Popular Resources
- Popular amplifiers
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Metronom Real-Time Operating System RTOS for AVR microcontrollers
- Learn C language for AVR microcontrollers easily (with video tutorial) (Yan Yu, Li Jia, Qin Wenhai)
- ATmega16 MCU C language programming classic example (Chen Zhongping)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- PyBoard W5500 firmware compilation issue
- ST MEMS Device Resource Library - Hardware Design Guide
- LIS2MDL three-axis magnetometer package and code
- Live broadcast with prizes: Enter the TI robot production class, starting on Friday, reservations are in progress! (Share 100% to get gifts)
- Explanation on DSP devices and general-purpose processors (GPP)
- About electromagnetic shielding
- About Phase Modulation
- I am confused about K60, hope for your advice
- Coding and decoding of MSP430 infrared remote control
- Graduation project help