#include "defs.h"
#include <avr/eeprom.h>
//------Fucntions for NMR Area in eeprom
static volatile unsigned int read_address=2048;
static volatile unsigned int write_address=2048;
void init_eeprom(void) {
read_address = 2048;
write_address = 2048;
}
void init_eeprom_read(void) {
read_address = 2048;
}
void init_eeprom_write(void) {
write_address = 2048;
}
int get_eeprom_write_address(void) {
return write_address;
}
int eeprom_getc(void) {
if(read_address<4096) {
loop_until_bit_is_clear(EECR, EEWE);
EEAR = read_address;
EECR |= _BV(EERE);
read_address++;
return EEDR;
} else {
return -1;
}
}
int eeprom_putc(char store_byte) {
if (write_address<4096) {
loop_until_bit_is_clear(EECR, EEWE);
EEAR = write_address;
EEDR = store_byte;
EECR |= _BV(EEMWE);
EECR |= _BV(EEWE);
write_address++;
return 1;
} else {
return -1;
}
}
void eeprom_puts(const char *s) {
while (*s)
eeprom_putc(*s++);
}
//------Fucntions for Parameter Area in eeprom
int eeprom_read(int address) {
if(address<2047) {
loop_until_bit_is_clear(EECR, EEWE);
EEAR = address;
EECR |= _BV(EERE);
return EEDR;
} else {
return -1;
}
}
int eeprom_write(int address, char store_byte) {
if (address<2047) {
loop_until_bit_is_clear(EECR, EEWE);
EEAR = address;
EEDR = store_byte;
EECR |= _BV(EEMWE);
EECR |= _BV(EEWE);
return 1;
} else {
return -1;
}
}
- Board index
- Search
-
- It is currently Sun Jun 15, 2025 9:26 pm
- All times are UTC+05:30
C Code for Interfacing EEPROM in AVR MCU
Microcontroller Topics
Jump to
- Programmable Electronics
- ↳ Arduino
- ↳ Raspberry Pi
- ↳ Microcontrollers
- ↳ FPGA
- ↳ Digital Signal Processors
- ↳ Other
- Programming
- ↳ Web programming
- ↳ PHP & MySQL
- ↳ ASP & ASP.Net
- ↳ .Net & Other Programming
- ↳ .NET Programming
- ↳ Visual Basic Programming
- ↳ Java Programming
- ↳ C/C++ Programming
- Engineering
- ↳ Electronics & Electrical Engineering
- ↳ Embedded Systems
- ↳ Computer Science
- ↳ Software Engineering
- ↳ Data Structures & Algorithms
- ↳ Programming Languages & Compiler Theory
- ↳ Operating Systems
- ↳ Cryptography
- ↳ Computer Networks
- ↳ SQL & Database
- ↳ Computer Architecture
- ↳ Graphics & Vision
- ↳ Artificial Intelligence
- ↳ Neural Networks
- ↳ Multimedia
- ↳ Mathematics
- ↳ Other
- ↳ Control Systems & Robotics
- ↳ Mechanical
- ↳ Thermodynamics
- ↳ Fluid Dynamics
- ↳ Aerodynamics
- ↳ Manufacturing
- ↳ Energy
- ↳ Dynamics
- ↳ Statics
- ↳ Automobile
- ↳ Other
- ↳ Other
- Operating Systems
- ↳ Windows
- ↳ Linux
- ↳ Mac OS
- ↳ Android
- ????? ????
- ↳ ???????? ?????
- ↳ ??????? ???? ?????
- ↳ ????? ?????? ???? (Buy Guide)
- ↳ ??????? ???? ??????? (Where to buy)
- ↳ ????????? ???????? (Recommend - Complain - Review)
- General
- ↳ News & Announcements
- ↳ General Discussions
- ↳ Viruses, Trojans, Spyware and Adware
- ↳ Computer & Network Security
- ↳ Web Related
- Members Zone
- ↳ Project Assistance
- ↳ Advertising
- ↳ Jobs & Investment Opportunities
- ↳ Introductions
- ↳ Presents & Donations
- ↳ Entertainment
- ↳ Music & Albums
- ↳ Movies
- ↳ Games