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 array to 24lc256

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



Joined: 17 Oct 2005
Posts: 26

View user's profile Send private message

write array to 24lc256
PostPosted: Sat Mar 04, 2006 2:36 pm     Reply with quote

hi i am trying to write an array with 4 elements each holding an int16 value to a 24lc256. i have managed to get the eeprom connected to the pic 16f877 and am able to write and read an int value using the ccs 24256.c driver. can anyone point me in the right direction to solving this problem as i am a bit stuck.

many thanks for any help given
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Sat Mar 04, 2006 2:44 pm     Reply with quote

Think about your array as being 8 int8's. That's nothing more than 8 single byte writes.
King Virus



Joined: 02 Mar 2006
Posts: 14
Location: Italy

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Sun Mar 05, 2006 3:38 am     Reply with quote

Mark wrote:
Think about your array as being 8 int8's. That's nothing more than 8 single byte writes.


If you really need int16 then you should work with shifting...

Let me explain:

Code:
        Write_Ext_Eeprom(5, h>>8); //  Write 1. Byte of variable "h"(declared as long or int16) to EEPROM position 5
        Write_Ext_Eeprom(6, h);    //  Write 2. Byte of variable "h"(declared as long or int16) to EEPROM position 6


As you can see, the first instruction will shift the MSB of "h" to the LSB of "h":

Let�s suppose that the value of "h" is:
Code:

      MSB        LSB
h = 10101010 00000000


then it will be after shifting (h>>8):

Code:

      MSB        LSB
h = 00000000 10101010


Now the write instruction (it is a 8bit write instruction) will handle yust the LSB of "h". So if you write it now into the EEPROM yust the LSB will be saved !

Thats all ! Now YOU have to combine it with some other code to handle 4 variables of type int16 !
_________________
*** A good forum is a forum where people respect eatch other ! ***
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 05, 2006 5:57 pm     Reply with quote

Quote:

I am trying to write an array with 4 elements each holding an int16 value
to a 24lc256. Can anyone point me in the right direction to solving this
problem as I am a bit stuck.

Also look at the make8() function in the CCS manual. It provides an
easy way to extract the desired byte from an int16 or int32 variable.
It's provided for this purpose.
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