245
#include <xc.h> #include "i2c.h" #include "eeprom.h" #pragma config FOSC = HS // Oscillator Selection bits (HS oscillator) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR disabled) #pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit #pragma config CPD = OFF // Data EEPROM Memory Code Protection bit #pragma config WRT = OFF // Flash Program Memory Write Enable bits #pragma config CP = OFF // Flash Program Memory Code Protection bit #define _XTAL_FREQ 16000000 #define WRITE_BUTTON RB0 // Define RB0 as the write button #define READ_BUTTON RB1 // Define RB1 as the read button void main(void) { I2C_Master_Init(100000); // Initialize I2C Master at 100kHz unsigned int Address = 0x0020; // Start address for EEPROM unsigned char Data = 0x04; // Initial data to write TRISB = 0x03; // Set RB0 and RB1 as inputs (buttons) TRISD = 0x00; // Set PORTD as output for display