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

18f26k22 preload EEPROM

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



Joined: 27 Oct 2012
Posts: 8
Location: united kingdom

View user's profile Send private message

18f26k22 preload EEPROM
PostPosted: Thu Jan 02, 2014 7:17 pm     Reply with quote

hi can't find the answer to this anywhere and hope someone can help I want to preload the eeprom of my device with data on loading, I have done this previously on 16f1936 using
Code:
#rom 0xF00000={0x00, //0x00     bootloader startup
                           0x00   //0x81     number of samples

                           }

however on the 18f26k22 it says this causes a verification error as the address for the start of the memory is wrong what should be the correct start address for the EEPROM be , i have tried the data sheet but didn't seem to find it

thanks in advance

edit : 16f1936 was #rom 0xF000 (before someone points out it's wrong!)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 02, 2014 8:05 pm     Reply with quote

This is the easy way to do it in CCS. Let the compiler lookup the
eeprom address for you from its database:
Code:
#ROM getenv("EEPROM_ADDRESS") = {0x55, 0xAA}


If it doesn't work, then post your CCS compiler version.
technomation



Joined: 27 Oct 2012
Posts: 8
Location: united kingdom

View user's profile Send private message

PostPosted: Thu Jan 02, 2014 8:41 pm     Reply with quote

hi thanks for the response,
just tried that and it works but only upto
#ROM getenv("EEPROM_ADDRESS") +0x70

after you go above this you get a verification error on loading to the pic

you can still access memory above 0x70 but not without deleting part of the previous #rom segment so seems like somekind of timout

any ideas ?

software is v5.016
thanks in advance (as it's 0240am here)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 02, 2014 9:02 pm     Reply with quote

A verification error comes from a programmer. What programmer are
you using ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 02, 2014 9:16 pm     Reply with quote

I compiled the program shown below in MPLAB and then used the View
menu to look at eeprom values set by the compiler. It's setting eeprom
starting at address 0x80 to 0x55, 0xAA. Note that I have added the 'int8'
qualifier to the #rom statement, so the compiler fills eeprom with byte
data, instead with 16-bit words. Try this program and see what happens:
Code:

#include <18F26K22.h>
#fuses INTRC_IO, BROWNOUT, PUT, NOWDT
#use delay(clock=4M)

#rom int8 getenv("EEPROM_ADDRESS") + 0x80 = {0x55, 0xAA}

//===================================
void main()
{
 
while(1);
}


This test was done entirely in MPLAB. It was not programmed into a
physical PIC chip.
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Fri Jan 03, 2014 12:26 am     Reply with quote

Another option if you have room in Program memory - let the cpu initialize the eeprom the first time. Typically, it is a good idea to have a check-byte to allow you to verify the data in eeprom. On first start-up, that check byte is either 0 or FF (I forget). If it is in that state, then call a routine to set the initial values in eeprom and then set the checkbyte to the checksum or whatever you want to use. First run initializes the eeprom, from then on, all is normal (although you could use the init routine again if you wanted if something happened to corrupt the eeprom or you wanted to set everything back to the initial state).

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
technomation



Joined: 27 Oct 2012
Posts: 8
Location: united kingdom

View user's profile Send private message

PostPosted: Fri Jan 03, 2014 7:06 am     Reply with quote

thanks for all your help guys

the programmer is a icd-u64

PCM you pointed out something I had never realised before #rom takes 16bit data! (which is actually the fix)

you know when the light bulb comes on..."I've just done things that way because I always have I works and I've never thought about it since" this is one of those moments...

all my data I store in the eeprom is actually 16 bit data.... I've been splitting it down into 8 bit chunks and inserting them one by one into a huge #rom segment (190 of them) , I've done this on pic projects (all 16f's until now) for as long as I've used the on chip eeproms which is years ...

just goes to show you learn newer better ways to do things everyday and why forums and there members are so important!

I've just converted the file into 16bit rom values... I now don't fear having to look at the eeprom file! (as it now contains real 16 bit data!)

but most importantly the verification error has gone away!

thanks once again
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