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

#rom address for 18f4685 ?

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



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

#rom address for 18f4685 ?
PostPosted: Tue Apr 08, 2008 5:41 pm     Reply with quote

Hello,

I have spent enough time looking for the #rom help in this forum, but I couldn't find my answer. May be one of you guys can help me to clear few things?


1.
What is the #rom address for pic18f4685? I tried looking at the data sheet but I am not sure which one is it? And I dont know how to interpret the values shown on the data sheet.


2.
Is the # rom address a random address ? Or does it always has to be the same for a specific PIC? If yes why?



3.
I tried writing and reading from ROM and it worked but I didnt assign any #rom. Is it safe to do so? Is there a risk that some thing might overwrite it if we do so?



I appreciate your help.
Thanks in advance.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 08, 2008 6:12 pm     Reply with quote

Quote:
What is the #rom address for pic18f4685?

See the 18F4685 data sheet:
http://ww1.microchip.com/downloads/en/DeviceDoc/39761b.pdf

Look at page 53 in the Acrobat Reader, at this figure:
Quote:
FIGURE 5-1: PROGRAM MEMORY MAP AND STACK FOR PIC18F2682/2685/4682/4685 DEVICES

On the right side, it shows the memory map for the program memory
for the 18F4685. It starts at 00000h and goes up to address 17FFFh.
That's 96 KB of flash memory. There are two bytes per instruction, so
it's really 48K words of instructions.

That answers your question. However, from reading the rest of your
questions, I wonder if you are really asking about the Data EEPROM
address ? Data eeprom is different than Flash program memory.
Izzy



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

PostPosted: Tue Apr 08, 2008 7:10 pm     Reply with quote

Thanks a lot for your response!
Thats a big help.

Yes I was talking about the EEPROM that we can use to save the data in the PIC.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 08, 2008 7:55 pm     Reply with quote

The address of the data eeprom is usually given in the Programming
Specification for the PIC. Here's section in the spec for the 18F4685:
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 Programming Specification:
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.
Guest








PostPosted: Wed Apr 09, 2008 6:21 am     Reply with quote

Thanks for the reply once again.


One more question. I was trying this read and write EEPROM thing.
But it sometime when I restart the PIC it reads 0 instead of some values. Do I need to erase it before we write? dont they erase it automatically?

When ever I press a button it is suppose to write the page no. to EEPROM and when I restart the PIC it should read that page no. and program should go to that page no. But it is reading 0. I dont know why.

Any one?
Izzy



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

PostPosted: Wed Apr 09, 2008 6:36 pm     Reply with quote

Please some one help me here.

I noticed that if I write to EEPROM in debug mode and then turn power off and then turn back again it works fine.

But if I recompile while in debug mode is enabled then the value reads zero.

Why is that?
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Apr 09, 2008 7:14 pm     Reply with quote

Sounds like you forget to initialize one or more variables at startup. If you remove power from the processor and start up again then often the variables get the random value of 0. After a reset from the debugger the data in RAM is unchanged and variables still have the values from the last time you ran your program.

If you can't solve the problem than post a short and complete example program here.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 09, 2008 8:00 pm     Reply with quote

Quote:

When ever I press a button it is suppose to write the page no. to EEPROM
and when I restart the PIC it should read that page no. and program
should go to that page no.

Here is a demo program that should show you how to do it:
http://www.ccsinfo.com/forum/viewtopic.php?t=22109&start=17

I don't know what you mean by "debug" mode, but my advice is to
just run the program in standard "stand-alone" mode in real hardware.
The program shown in the link above was tested on a PicDem2-Plus
board.
Izzy



Joined: 27 May 2007
Posts: 106

View user's profile Send private message

PostPosted: Wed Apr 09, 2008 8:33 pm     Reply with quote

Thanks for the reply guys.

I cant post the whole program here because its getting way too long. But I will post the test code that I tried.

But one question, if we write something in EEPROM with debug enabled
in CCS compiler then if we recompile (again with debug enabled), will it erase the stored EEPROM values?


Code:

#include <18F4685.h>
#device ICD=TRUE
#device ADC=10
#fuses NOLVP,NOWDT
#use delay(clock=40,000,000)
#use rs232(stream=LCD, baud=9600, xmit=Pin_C6)
#rom 0xF00000 = {0}
#include <stdlib.h>
#include <math.h>



void main()
{

while(TRUE)
{
      if(input(PIN_B1) == false)
      {
      write_eeprom(0,9);
      delay_ms(10);
      fprintf(LCD,"Done");
      delay_ms(500);
      }



      if(input(PIN_B0) == false)
      {
      fprintf(LCD,"%u", read_eeprom(0));
      delay_ms(500);
      }

}

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 09, 2008 11:38 pm     Reply with quote

For ICD2:
http://www.ccsinfo.com/forum/viewtopic.php?t=33108&highlight=preserve+eeprom

For ICD-U40:
http://www.ccsinfo.com/forum/viewtopic.php?t=30633&highlight=preserve+eeprom
Guest








PostPosted: Thu Apr 10, 2008 6:13 am     Reply with quote

Under Erase I only have "Bulk Erase" and "No Erase".

Should I select No erase?
Guest








PostPosted: Thu Apr 10, 2008 11:44 am     Reply with quote

One more question,

After writing software for 3 weeks I tried to download the software into the microcontroller and it is showing weird characters in LCD instead of some words.

It worked perfectly fine when I try in debug more with ICD.

What is wrong?
As far as I can remember I know we need to remove ICD=TRUE from the code and it was suppose to work.


Thanks in advance.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 10, 2008 12:07 pm     Reply with quote

This thread has instructions on how to create and download a program
in "Stand-alone" mode with the ICD-U40 (i.e., not using it as a debugger,
just using it as a programmer).
http://www.ccsinfo.com/forum/viewtopic.php?t=28356
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