CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

SOLVED: eeprom_read and eeprom_write not working on PIC18F

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
JackB



Joined: 04 Mar 2016
Posts: 32
Location: Netherlands

View user's profile Send private message

SOLVED: eeprom_read and eeprom_write not working on PIC18F
PostPosted: Sat Mar 19, 2016 3:25 pm     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Sat Mar 19, 2016 3:36 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Mar 19, 2016 3:56 pm     Reply with quote

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

View user's profile Send private message AIM Address

PostPosted: Sat Mar 19, 2016 4:29 pm     Reply with quote

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: 9245
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Mar 19, 2016 4:29 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Mar 20, 2016 2:46 am     Reply with quote

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!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group