View previous topic :: View next topic |
Author |
Message |
JackB
Joined: 04 Mar 2016 Posts: 32 Location: Netherlands
|
SOLVED: eeprom_read and eeprom_write not working on PIC18F |
Posted: Sat Mar 19, 2016 3:25 pm |
|
|
Hi friends,
I noticed the eeprom_read and eeprom_write functions are no longer working properly. (PIC18F67K90)
It reads 0x00 even if I wrote some values to some location just before.
I'm sure it worked when my project just started and had only a few lines of code.
Something must have gone wrong, but what?
Regards,
Jack.
Code: |
void show_eeprom_contents(void)
{
// Write some EEPROM contents
write_eeprom(0x02, 0x55);
write_eeprom(0x03, 0xaa);
// list EEPROM contents
uint16 address, line;
fprintf(USB_STREAM, "EEPROM content:\r\n");
fprintf(USB_STREAM, "Address 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\r\n");
fprintf(USB_STREAM, "---------------------------------------------------------\r\n");
for (line = 0; line < 32; line+=16) {
fprintf(USB_STREAM, "%04x ", line);
for (address = 0; address < 16; address++) {
if (address == 8)
fprintf(USB_STREAM, " ");
uint8 value = read_eeprom(address+line);
fprintf(USB_STREAM, "%02x ", value);
}
fprintf(USB_STREAM, "\r\n");
}
fprintf(USB_STREAM, "\r\n");
}
|
Last edited by JackB on Sun Mar 20, 2016 2:44 am; edited 2 times in total |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Sat Mar 19, 2016 3:36 pm |
|
|
look at your .LST file for the compile of your program
see if you are accessing
0xF61h EEDATA EEPROM Data Register 0000 0000
0xF62h EEADR EEPROM Address Register Low Byte 0000 0000
oxF63h EEEPROM Address Register High Byte
also see
http://www.ccsinfo.com/forum/viewtopic.php?t=26245
and answer question #4 |
|
|
JackB
Joined: 04 Mar 2016 Posts: 32 Location: Netherlands
|
|
Posted: Sat Mar 19, 2016 3:56 pm |
|
|
Hi,
thanks for the quick response!
The lst file did not list any of those kind of lines.
However, I solved the problem, and corrected my typo the above code:
fprintf(USB_STREAM, "%02x ", version); <- note the wrong variable, stupid!
fprintf(USB_STREAM, "%02x ", value);
Regards,
Jack. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Sat Mar 19, 2016 4:29 pm |
|
|
Code: | CCS C (can't find version) |
the .LST file OUGHT to be where your compiled .HEX file is placed by the compiler .
can you find that ?
the version number of CCS will be in the head of the .LST file too.
without that -and your ability to find the .LST file - not much i can do for you.
if you are compiling for PIC18F67K90 it has to be at least version 5 of CCS
Last edited by asmboy on Sat Mar 19, 2016 4:30 pm; edited 1 time in total |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Sat Mar 19, 2016 4:29 pm |
|
|
Maybe you've set some 'fuses' to protect and it can't write anymore ??
Post 1st few lines of source and'or look at the fuses at the end of the listing.
Jay |
|
|
JackB
Joined: 04 Mar 2016 Posts: 32 Location: Netherlands
|
|
Posted: Sun Mar 20, 2016 2:46 am |
|
|
Hi asmboy,
you are right!
CCS PCH C Compiler, Version 5.055.
I overlooked a type, it worked, but I did not print the result.
That makes all of the difference! :-)
And I overlooked it, I guess I should sleep in time and have a look next day better, before posting first.
Thank you all for your help! |
|
|
|