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

locating in eeprom

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







locating in eeprom
PostPosted: Tue Oct 10, 2006 5:22 am     Reply with quote

Hi, can I "#locate" an array in eeprom?
I want to access an eeprom area writing or reading an array:

array[0] = 10;
temp = array[0];

Is it possible?

thanks!
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

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

PostPosted: Tue Oct 10, 2006 8:11 am     Reply with quote

Data EEPROM of the chip? or external eeprom?
picerno
Guest







locating in eeprom
PostPosted: Tue Oct 10, 2006 12:10 pm     Reply with quote

I want to locate in internal eeprom, but is it possible in external also?
Ttelmah
Guest







PostPosted: Tue Oct 10, 2006 2:38 pm     Reply with quote

Typemod.
This allows you to have variables declared using external storage (EEPROM etc.), and use them in your code. There i a fairly large overhead associated with this, and some temporary storage used. Gnerally it is only therefore 'worthwhile' for large external memories,rather than with th internal EEPROM.

Best Wishes
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

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

PostPosted: Tue Oct 10, 2006 2:48 pm     Reply with quote

V3.249 16F877A@20MHz
This is for internal data_eeprom
External can be used if you have the chip(24LC64). It is done differently
Code:
#include <16F877A.h>
#device *=16
#fuses hs,nowdt,noprotect,nolvp,put
#use delay(clock=20000000)
#use rs232(baud=19200,xmit=PIN_E2,invert,stream=debug,disable_ints)
#case
#zero_ram

//The below ROM is programed as the chip is programed
#define _array_1 0x2100  //note how 0x2100 is data_eprom location 0
#rom _array_1={0xBA,0xBB,0xBC,0xBD,0xBE,0xBF}

//--- Prototypes ---//
void DataEE_Write(int32 address, int8 * data, int8 size);
void DataEE_Read (int32 address, int8 * data, int8 size);

//--- Data EEPROM ---//
addressmod <,DataEE_Read,DataEE_Write,0x00,0xFF> DataEE;


//--- main ---//
main(){
  int8 DataEE array[10];
  fprintf(DEBUG,"Start\n\r");
  fprintf(DEBUG,"0x%X\n\r",array[0]);
  fprintf(DEBUG,"0x%X\n\r",array[1]);
  fprintf(DEBUG,"0x%X\n\r",array[2]);
  fprintf(DEBUG,"Done\n\r");
  while(1);
}
// Below should be read-before-write
// First Read data. Then only write if the information is different
// Takes longer but cuts down on writes that can wear out the eeprom
////--- DataEE_Write ---//
//void DataEE_Write(int32 address, int8 * data, int8 size){
//  //shell function to test if call is made.  Doesn't do anything
//  int i;
//  fprintf(DEBUG,"W-A=%lu, S=%u\n\r",address,size);
//  for(;size;size--,data++,address++){
//    write_eeprom(address,*data);
//  }
//}
//--- DataEE_Read ---//
void DataEE_Read(int32 address, int8 * data, int8 size){
  for(;size;size--,data++,address++){
    *data=read_eeprom(address);
  }
}

This will add a bunch to the RAM usage because the compiler is taking care of the addresses for you. I find it better to just #ROM and read with a straight read_eeprom(address);
picerno
Guest







locating in eeprom
PostPosted: Wed Oct 11, 2006 2:04 am     Reply with quote

it is interesting, but I don't find documentation about "addressmode". What'is this?
Ttelmah
Guest







PostPosted: Wed Oct 11, 2006 2:13 am     Reply with quote

Typemod, and addressmod, are different names for the same thing. The 'older' name was typemod, and in V4, it is to be called 'addressmod'. V3.249, supports both. If you go to the CCS main page, and type 'typemod' into the search, the top entry, gives an example page showing how it is used, and what it can do.

Best Wishes
picerno
Guest







PostPosted: Wed Oct 11, 2006 2:28 am     Reply with quote

Wonderful, I will try it with a 3D array. It will work?

thanks, thanks
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