EEPROM read/write example for the PIC12F629 and PIC12F675 using MikroC PRO.
This repository contains a simple and didactic example of how to access the internal data EEPROM of the PIC12F629 and PIC12F675.
The project provides reusable routines for:
- writing one byte to EEPROM
- reading one byte from EEPROM
- validating the EEPROM address range
It is intended as a basic embedded systems example for students, hobbyists, and developers working with PIC microcontrollers.
- Microcontrollers:
PIC12F629,PIC12F675 - Language:
C - IDE:
MikroC PRO v7.2.0 - Clock:
4 MHz
The PIC12F629 and PIC12F675 provide:
- 128 bytes of internal data EEPROM
- valid address range from
0x00to0x7F
main.c— example application using the EEPROM routineseeprom.c— EEPROM implementationeeprom.h— EEPROM public interface
PIC12F629.pdf— microcontroller documentation
- EEPROM byte write routine
- EEPROM byte read routine
- address limiting to valid EEPROM range
- write status return for error handling
- reusable module split into
.hand.c
Writes one byte to the selected EEPROM address:
- validates the address range
- selects data EEPROM access
- enables write mode
- temporarily disables global interrupts
- performs the required unlock sequence
- starts the write cycle
- waits until the write operation finishes
- returns a status code
Reads one byte from the selected EEPROM address:
- validates the address range
- selects data EEPROM access
- loads the EEPROM address
- starts the read cycle
- returns the byte stored in
EEDAT
#include "eeprom.h"
void main()
{
unsigned char value;
unsigned char status;
status = write(0x2A, 0x10);
if (status == EEPROM_WRITE_OK)
{
value = read(0x10);
}
while (1)
{
}
}EEPROM_WRITE_OK→ write completed successfullyEEPROM_WRITE_ERROR→ write operation failed
This implementation supports EEPROM addresses in the following range:
0x00to0x7F
If an address above the valid range is passed, it is limited to the maximum valid EEPROM address.
This project is a small embedded systems study/example repository focused on EEPROM access with the PIC12F629 and PIC12F675.