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

Write a Float variable in the internal EEPROM memory

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



Joined: 23 Oct 2009
Posts: 1
Location: Costa Rica

View user's profile Send private message

Write a Float variable in the internal EEPROM memory
PostPosted: Fri Oct 23, 2009 2:54 pm     Reply with quote

Hello, I'm trying to save a float variable, that I'm using in a program in the internal EEPROM memory. I found this example in CCS FAQ, but I still don't know how to save my float variable.

Code:

WRITE_FLOAT_EXT_EEPROM(long int n, float data) {
   int i;

   for (i = 0; i < 4; i++)
      write_ext_eeprom(i + n, *((int8*)&data + i) ) ;
}

float READ_FLOAT_EXT_EEPROM(long int n) {
   int i;
   float data;

   for (i = 0; i < 4; i++)
      *((int8*)&data + i) = read_ext_eeprom(i + n);

   return(data);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Oct 23, 2009 3:48 pm     Reply with quote

Use the routines from this CCS driver file. It has routines for internal eeprom:
Quote:
c:\program files\picc\drivers\internal_eeprom.c

The routines have instructions:
Quote:

// Purpose: Write a floating point number to internal eeprom
// Inputs: 1) An eeprom address. Four eeprom locations will be used.
// 2) The floating point number to write to internal eeprom
// Outputs: None

void write_float_eeprom(INT_EEPROM_ADDRESS address, float data)

// Purpose: Read a floating point number from internal eeprom
// Inputs: An eeprom address
// Outputs: The floating point number read from the internal eeprom
float read_float_eeprom(INT_EEPROM_ADDRESS address)
mutthunaveen



Joined: 08 Apr 2009
Posts: 100
Location: Chennai, India

View user's profile Send private message

i had the same question
PostPosted: Sat Oct 24, 2009 7:07 am     Reply with quote

thanks PCM programmer
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