324
while (1) { if (WRITE_BUTTON == 0) { // Check if write button is pressed __delay_ms(20); // Debounce delay if (WRITE_BUTTON == 0) { // Confirm button press // Write data to EEPROM EEPROM_Write(Address++, Data++); // Write first data EEPROM_Write(Address++, Data++); // Write second data EEPROM_Write(Address, Data); // Write last data __delay_ms(1000); // Delay to prevent multiple writes } } if (READ_BUTTON == 0) { // Check if read button is pressed __delay_ms(20); // Debounce delay if (READ_BUTTON == 0) { // Confirm button press Address = 0x0020; // Reset address to start of data // Read data from EEPROM and display on PORTD PORTD = EEPROM_Read(Address++); // Read first data __delay_ms(1000); PORTD = EEPROM_Read(Address++); // Read second data __delay_ms(1000); PORTD = EEPROM_Read(Address); // Read last data } } } }