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 support@ccsinfo.com

#rom on PIC18F8722

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



Joined: 09 Jul 2004
Posts: 70

View user's profile Send private message

#rom on PIC18F8722
PostPosted: Sun Apr 06, 2008 9:33 pm     Reply with quote

I am trying to use the #rom to preload my eeprom with values. I have added
#rom int8 0xF00000={0x61}
to the beginning of my program and then in the body, i am reading the eeprom
read=read_eeprom(0);
However, when i look at what is in read, i find that it is 0xFF instead of 0X61. I do not see what i am doing incorrectly. I have looked at the forum and it appears that it should be as simple as i have done, but i am not getting the right values.
V 4.050
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 06, 2008 10:17 pm     Reply with quote

Post a short test program that has a #rom statement and read_eeprom()
statement, and a printf() statement to display the values that were read.
Be sure to post the #include, #fuses, and #use delay() statements,
and a while(1) statement at the end of main(). (10 lines of code, max).
Matro
Guest







PostPosted: Mon Apr 07, 2008 6:40 am     Reply with quote

Your code is right because by importing the hex of the following code
Code:

#include <18F8722.h>

#ROM int8 0x700000 = {0x61}

void main()
{
while(1);
}

in MPLAB and looking at the EEPROM I can see the 0x61 in the first EEPROM byte.
What programming software are you using?

Matro.
nmeyer



Joined: 09 Jul 2004
Posts: 70

View user's profile Send private message

PostPosted: Mon Apr 07, 2008 11:39 am     Reply with quote

I have am using the CCS bootloader and i am loading the program hex file with the SIOW.exe out of the CCS compiler. I noticed you have 0x700000 as the #Rom address. is this a typo or does the 18F8722 have a different location for the eeprom?
PCM programmer- I will try your suggestion, i just have not gotten to it yet.
Matro
Guest







PostPosted: Mon Apr 07, 2008 11:48 am     Reply with quote

My mistake. I've done some tests with some devices and copy my last test...
The address is 0xF00000 for that device too.
Sorry for the mistake.

Matro.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 07, 2008 11:49 am     Reply with quote

This thread has an example of a test program for the internal eeprom.
You just need the first part, where it reads and displays the values that
were set with the ROM statement.
http://www.ccsinfo.com/forum/viewtopic.php?t=32722

The address of the data eeprom is usually given in the Programming
Specification for the PIC. Here's section in the spec for the 18F8722:
Quote:
5.5 Embedding Data EEPROM Information in the HEX File

When embedding data EEPROM information
in the hex file, it should start at address F00000h.


Here's how to find and download the specs:
Go to the Microchip Data Sheet Finder page (bookmark this page):
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2046
Select your PIC in the drop-down box. Wait for the page to load.
Then locate the link for the Programming Spec and download it.
nmeyer



Joined: 09 Jul 2004
Posts: 70

View user's profile Send private message

PostPosted: Mon Apr 07, 2008 12:11 pm     Reply with quote

Thanks. I was reading through the data sheet and either skipped over that or did not read that part of Setion 5. Looks like i am doing the #rom correctly, i can also write to and read from eeprom in the program, so it is something else that is causeing the #rom not to work. I have to review my fuses and the rest of the set up of the program.
Matro
Guest







PostPosted: Mon Apr 07, 2008 12:25 pm     Reply with quote

Since SIOW is a program dedicated to serial communication, I guess you're using a bootloader to program the PIC.
If this is the case, everything's normal because a bootloader doesn't take in charge the EEPROM programming.
Have I correctly understood what's your programming software flow?

Matro.
nmeyer



Joined: 09 Jul 2004
Posts: 70

View user's profile Send private message

PostPosted: Mon Apr 07, 2008 12:46 pm     Reply with quote

You are correct. I program the main code through the serial port into the PIC.
Matro
Guest







PostPosted: Mon Apr 07, 2008 12:58 pm     Reply with quote

nmeyer wrote:
You are correct. I program the main code through the serial port into the PIC.

So you are using a bootloader that isn't able to program the EEPROM (like almost all bootloaders).

So it's normal that you read 0xFF in EEPROM (0xFF is default value i.e. the value of a never used chip or an erased one).

Matro.
nmeyer



Joined: 09 Jul 2004
Posts: 70

View user's profile Send private message

PostPosted: Mon Apr 07, 2008 1:52 pm     Reply with quote

So, then to use the #rom, i will have to use that in the bootloader code instead of my main program.
Matro
Guest







PostPosted: Mon Apr 07, 2008 2:04 pm     Reply with quote

I don't know your exact project but according to your needs and skills, you can :
- program your PIC with a ISP programmer if it is possible in your context
- modify the bootloader code for it to manage EEPROM writing (and you probably need to create your own PC application)
- locate your data in program memory instead of EEPROM memory.

Matro.
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Tue Apr 08, 2008 1:50 am     Reply with quote

Rather than using the #rom directive you can initialise the eeprom with a bit of code.
Knowing that erased eeprom = 0xFF you just need to use a byte of eeprom to store a version number. At the start of your main program just read this and if it is not at the revision you require write default values to eeprom and write a new version number to that address. This way if you need to write new default values to eeprom then you can compare the version number.
This will also offer protection against loss of eeprom data (erase). because each time your code starts it will read the version number and if it is 0xFF it will just re-write the default values back in. With doing it using the #ROM way if the eerpom gets erased somehow you will have to re-program it.


If these values are fixed and will never change then just use program memory instead of eeprom.
nmeyer



Joined: 09 Jul 2004
Posts: 70

View user's profile Send private message

PostPosted: Tue Apr 08, 2008 7:14 am     Reply with quote

That is what i am planning to do for now. The values in eeprom are set to "default" at first power up and then the user can at that point go through all of them and change them and save them back to eeprom to use unitl they change them 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