Gouthami c v
...what else should i check...
There are three things at least
as important as writing code for an application:
I simply never (that's NEVER) write a single line of code for a new project until I have formulated a test plan. I don't always formalize it with external documentation, but I always (that's ALWAYS) know how I am going to test it before actually starting. Period. Full stop.
For testing EEPROM, when you want to make sure the EEPROM retains last values written from a previous run, here's a REALLY BIG DEAL:
When you program with a PICkit3 (maybe other programmers as well), the device may be reset several times before programming is complete. The device will begin to run each time and then be reset again, and that may disturb previous conditions.
Therefore, upon startup, before writing to EEPROM:
I always give it a delay of a second or so to make sure previous values are still in the EEPROM when it starts running "for real."
Here's my test program for byte-at-a time writing:
[/Begin Quasi-code for main()]
- Begin main()
- Initialize everything that needs to be initialized.
- Set the 9-bit byte address to zero (or whatever other address you want to start at).
- Begin Main loop
- Delay for a second or two. Maybe __delay_ms(1000) or some such thing.
- Read and print old data value at the byte address.
- Change the data to something else.
- Write the new data to the same byte address. Print what you are writing.
- Do ACK Polling to make sure EEPROM internal write cycle has finished.
- Read and print the new data value.
- Change the byte address. Maybe just increment it.
- End of Main loop
- End of main()
[/End Quasi-code for main(
Here is the output from my test program.
I reset or power-cycled the circuit after four times through the loop each time.
You can start at some other address. You can let it go as long as you want.
The important point is that as you begin each time you can compare the value with the last thing you wrote at each address.
Note that I always print some information before entering the main loop. That makes it easy to see where it gets reset.
I printed out the loop count and the byte address followed by old and new data each time through the loopCompiled on Sep 20 2019 at 08:51:20 by XC16 version 10401: 0x000 eedata = 0xA8 Writing 0xAA New value = 0xAA2: 0x001 eedata = 0xEE Writing 0xF1 New value = 0xF13: 0x002 eedata = 0x36 Writing 0x3A New value = 0x3A4: 0x003 eedata = 0x6B Writing 0x70 New value = 0x70Compiled on Sep 20 2019 at 08:51:20 by XC16 version 10401: 0x000 eedata = 0xAA Writing 0xAC New value = 0xAC2: 0x001 eedata = 0xF1 Writing 0xF4 New value = 0xF43: 0x002 eedata = 0x3A Writing 0x3E New value = 0x3E4: 0x003 eedata = 0x70 Writing 0x75 New value = 0x75Compiled on Sep 20 2019 at 08:51:20 by XC16 version 10401: 0x000 eedata = 0xAC Writing 0xAE New value = 0xAE2: 0x001 eedata = 0xF4 Writing 0xF7 New value = 0xF73: 0x002 eedata = 0x3E Writing 0x42 New value = 0x424: 0x003 eedata = 0x75 Writing 0x7A New value = 0x7A
post edited by davekw7x - 2019/09/20 11:09:23