Hi I would like to store a set of numbers on the eeprom and then send them to the PC and view them on the USART terminal. I have this much working. I am storing values from 4 to 23. However i would like to run the code a second time and view the values on the eeprom again (just to see if they are being stored). However when i reprogram the PIC to to read the EEPROM each address of the eeprom just reads 255. Are the values being erased when i reprogram the PIC? Or are they even being stored in the first place? any help would be great. The code is shown below.
int i;
int k ;
unsigned short temp_res, temp_res2;
void main() {
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
// PORTB = 0; // Initial PORTB value
TRISB = 0; // Set PORTB as output
// PORTD = 0;
TRISD = 0;
j = 4;
for (i = 0; i < 21; i++) // Write some data to EEPROM
EEprom_Write(i, j++);
for (i = 0; i < 21; i+=2) {
USART_Init(19200); // Initalize USART (19200 baud rate, 1 stop bit, no parity...)
temp_res = PORTD; // Read 10-bit ADC from AN2 and discard 2 LS bits
temp_res2 = PORTB ;
Delay_ms(100);
PORTD = EEPROM_Read(i); // Read data and display it on PORTB
PORTB = EEPROM_Read(i+1) ;
USART_Write(temp_res); // Send ADC reading as byte
USART_Write(temp_res2);
Delay_ms(500);
}
}
int i;
int k ;
unsigned short temp_res, temp_res2;
void main() {
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
// PORTB = 0; // Initial PORTB value
TRISB = 0; // Set PORTB as output
// PORTD = 0;
TRISD = 0;
j = 4;
for (i = 0; i < 21; i++) // Write some data to EEPROM
EEprom_Write(i, j++);
for (i = 0; i < 21; i+=2) {
USART_Init(19200); // Initalize USART (19200 baud rate, 1 stop bit, no parity...)
temp_res = PORTD; // Read 10-bit ADC from AN2 and discard 2 LS bits
temp_res2 = PORTB ;
Delay_ms(100);
PORTD = EEPROM_Read(i); // Read data and display it on PORTB
PORTB = EEPROM_Read(i+1) ;
USART_Write(temp_res); // Send ADC reading as byte
USART_Write(temp_res2);
Delay_ms(500);
}
}