View previous topic :: View next topic |
Author |
Message |
Izzy
Joined: 27 May 2007 Posts: 106
|
#rom address for 18f4685 ? |
Posted: Tue Apr 08, 2008 5:41 pm |
|
|
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
|
|
Posted: Tue Apr 08, 2008 6:12 pm |
|
|
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
|
|
Posted: Tue Apr 08, 2008 7:10 pm |
|
|
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
|
|
Posted: Tue Apr 08, 2008 7:55 pm |
|
|
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
|
|
Posted: Wed Apr 09, 2008 6:21 am |
|
|
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
|
|
Posted: Wed Apr 09, 2008 6:36 pm |
|
|
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
|
|
Posted: Wed Apr 09, 2008 7:14 pm |
|
|
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
|
|
Posted: Wed Apr 09, 2008 8:00 pm |
|
|
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
|
|
Posted: Wed Apr 09, 2008 8:33 pm |
|
|
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
|
|
|
Guest
|
|
Posted: Thu Apr 10, 2008 6:13 am |
|
|
Under Erase I only have "Bulk Erase" and "No Erase".
Should I select No erase? |
|
|
Guest
|
|
Posted: Thu Apr 10, 2008 11:44 am |
|
|
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
|
|
Posted: Thu Apr 10, 2008 12:07 pm |
|
|
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 |
|
|
|