WARNING: THE CODE HAS BEEN TESTED AND WORKING SUCCESSFULLY.

AIM: To make EEPROM interfacing to 8051 microcontrollers simpler with few functions pretested and no need further debugging. (AT89C4051/ AT89C51/ AT89C52/ AT89C55/ AT89S4051/ AT89S51/ AT89S52/ AT89S55 devices supported).

BRIEF DESCRIPTION:
Interface Type: I2C Bit Banging mode.
EEPROM Type: 24LC512 (Tested)
Max Size on Flash Memory: 564Bytes.
RAM use: 20Byte.
Microcontroller: AT89S52

TEST CIRCUIT:( KINDLY NOTE THE CIRCUIT ONLY INCLUDES I2C AND EEPROM CONNECTIONS. MICROCONTROLLER CONNECTIONS ARE NOT SHOWN)




How to assign pins inside code???

1. Go to eeprom.h
2. change this area highlighted in red here. Assign pins properly.
3. Include this files into your project.
4. Include eeprom.h in main.c
5. Make use of the functions given below and you are good to go.

Functions Added:

The functions below are the only functions you need to know for data reading and writing. The user has access to all 0x0000 to 0xFFFF addressing space.

To write data to specific address use this instruction:

void api_eeprom_write(BYTE addr_h,BYTE addr_l, BYTE data_b); 

where,

BYTE addr_h = higher order of address.
BYTE addr_l = lower order of address.
BYTE data_b = data to be written.

No Return Value.




The size of all above variables is 8-Bit or 1Byte.

How to use it???
unsigned char test=0x26; //8bit variable
//enter test variable on eeprom at location 0x1022
api_eeprom_write(0x10,0x22, test);



BYTE api_eeprom_read(BYTE addr_h,BYTE addr_l);
//Read data from specific address

where,

BYTE addr_h = higher order of address.
BYTE addr_l = lower order of address.

Return Value = Data at that address 8bit

How to use it???

unsigned char test; //8bit variable
//read eeprom at location 0x1022 and store the data into test variable
test = api_eeprom_read(0x10,0x22);


 THE CODE IS AVAILABLE HERE


Further modifications will include page writes/reads and array writes/reads. (code will be releasing shortly)

Thank You for Reading,

Macjan Camilo Fernandes



0

Add a comment

Loading