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

Preload the PIC18F452 EEPROM

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



Joined: 30 Jan 2008
Posts: 197

View user's profile Send private message

Preload the PIC18F452 EEPROM
PostPosted: Fri Oct 09, 2009 8:40 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Fri Oct 09, 2009 8:56 am     Reply with quote

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);
  }
}

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