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

how to store int16 value into the internal eeprom

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



Joined: 09 Aug 2007
Posts: 82
Location: TN, India

View user's profile Send private message Send e-mail

how to store int16 value into the internal eeprom
PostPosted: Sun Aug 19, 2007 10:42 am     Reply with quote

hai,

how store int16 value into the internal eeprom, please give sample code.
valemike
Guest







write an int16
PostPosted: Sun Aug 19, 2007 1:31 pm     Reply with quote

This is the code i've been using on a two year old program. I derived it from the FAQ, where they show an example using a float. But now that I look at it, perhaps i shouldn't be using "long int n"??? Maybe i should use int16 or unsigned long. Then again, isn't a long int also 16 bits?? who knows.

Code:

unsigned long READ_LONG_INT_EEPROM(long int n)
{
    int i;
    long int data;
   
   for (i = 0; i < 2; i++)
        *(&data + i) = read_eeprom(i + n);
    return(data);
}

void WRITE_LONG_INT_EEPROM(long int n, long int data)
{
    int i;

    restart_wdt();
    for (i = 0; i < 2; i++)
    {
        write_eeprom(i + n, *(&data + i) ) ;
    }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Aug 19, 2007 1:43 pm     Reply with quote

That FAQ article has been updated. Starting with vs. 4.021, pointer
arithmetic doesn't assume pointers are byte pointers.
From the CCS versions page:
Quote:
4.021 The & unary operator by default no longer returns a generic (int8 *)

In the revised FAQ article, notice how they cast the float pointer to an
int8 pointer, when they want to step through each of the 4 bytes in the
float:
http://www.ccsinfo.com/faq.php?page=write_eeprom_not_byte
karthickiw



Joined: 09 Aug 2007
Posts: 82
Location: TN, India

View user's profile Send private message Send e-mail

about eeprom
PostPosted: Mon Aug 20, 2007 10:29 am     Reply with quote

sir,

what is default value of internal eeprom.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 20, 2007 11:40 am     Reply with quote

When a new chip is received from the Microchip factory, the internal
eeprom value should be 0xFF. But I don't think they guarantee it.

You can make sure that it's set to 0xFF by selecting "Erase Part" from
the Programmer menu. This option is available in the Programmer
menu in MPLAB with the ICD2 programmer. I'm sure the CCS IDE
has a similar menu option.
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