|
|
View previous topic :: View next topic |
Author |
Message |
pilar
Joined: 30 Jan 2008 Posts: 197
|
Preload the PIC18F452 EEPROM |
Posted: Fri Oct 09, 2009 8:40 am |
|
|
I want to use the #ROM preprocessor directive to preload the PIC18F452 EEPROM with values at the time of programming the chip but I have a doubt , what is the start address of the eeprom.
Code: | #define putLong(value) {value,(value>>8),(value>>16),(value>>24)}
#rom 0x0??? = putLong(0x12345678)
#rom 0x0??? = putLong(0x9ABCDE)
|
|
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Fri Oct 09, 2009 8:56 am |
|
|
Yes, its a little confusing.
First location of data eeprom of 18F452
if doing a #rom use 0xf00000
but latter if using a read eeprom use address 0.
In general you have to refer to spec sheet.
From the PIC18 Programming Specification, Chapter 5.6
Quote:
When embedding data EEPROM information in the HEX file, it should start at address F00000h.
http://www.ccsinfo.com/forum/viewtopic.php?t=32480&highlight=rom+data+eeprom+18f452
This won't compile. This just shows how I use it.
Code: |
#include <18F452.h>
#fuses hs,wdt32,noprotect,nolvp,put
#use delay(clock=18432000,RESTART_WDT)
#use rs232(baud=19200,xmit=PIN_D7,invert,stream=DEBUG)
#case
#zero_ram
#build(reset=0x000:0x0007)
#define HARD_MAJOR (int8) 0
#define HARD_MINOR (int8) 0
#define FIRM_MAJOR (int8) 'K'
#define FIRM_MINOR (int8) 80
#define PROD_ID (int8) 3
#rom int8 0xf00000={HARD_MAJOR,HARD_MINOR,FIRM_MAJOR,FIRM_MINOR,PROD_ID}
//========================= Globals =================================//
struct def_kpd
{
int8 hard_major;
int8 hard_minor;
int8 firm_major;
int8 firm_minor;
int8 product_id;
}kpd_info;
//========================= Prototypes ==============================//
void init(void);
//========================= Main ====================================//
void main(void)
{
init();
while(1)
{
}
}
//========================= Functions ==============================//
//=== init ===// setup the initial settings
void init(void)
{
readParamsEEProm();
debug("H=%u.%02u ",kpd_info.hard_major,kpd_info.hard_minor);
debug("F=%C_%02u.c\n\r",kpd_info.firm_major,kpd_info.firm_minor);
}
//=== readParamsEEProm ===//
void readParamsEEProm(void)
{
//int8 addr;
int16 addr;
char *pntStruct;
pntStruct=&kpd_info;
for(addr=0;addr<sizeof(kpd_info);addr++,pntStruct++)
{
*pntStruct=read_eeprom(addr);
}
}
|
|
|
|
|
|
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
|