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

VAR 32 in lib linear_24LC512

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



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message

VAR 32 in lib linear_24LC512
PostPosted: Thu Nov 13, 2008 12:08 pm     Reply with quote

Hi,
in code linear_24lc512 listed below, how write a var 32 bits ?

Thanks.

Orcino


Code:
//////////////////////////////////////////////////////////////////////////////////
////        Library for lineal address to a bank of 8 24LC512 chip memory      ////
////                                                                           ////
////        0 to 0x07FFF                                                       ////
////                                                                           ////                                                                         ////
//// init_24512x8();  Call before the other functions are used                 ////
////                                                                           ////
//// writeByte24512x8(a,d); Write the byte (int8)d to the address (int32)a     ////
////                                                                           ////
//// d=ReadByte24512x8(a); Read the byte int8)d from the address (int32)a      ////
////                                                                           ////
////                                                                           ////
///////////////////////////////////////////////////////////////////////////////////


//#ifndef EEPROM_SDA

//#define EEPROM_SDA  PIN_B0
//#define EEPROM_SCL  PIN_B1

//#endif

//#use i2c(master,slow,sda=PIN_B0,scl=PIN_B1,force_hw)

#define MULTIPLE_EEPROM_ADDRESS int32
#define EEPROM_SIZE  524288

void init_ext_eeprom()
{
   output_float(PIN_B0);
   output_float(PIN_B1);

}


void writeByte_24512x8(int32 memaddress, int8 data){

   int16 address;
   int8  controlbyte;
   short int status;
   
   address=memaddress;

   controlbyte=(0xa0 | ((make8(memaddress,2))<<1));

   i2c_start();
   i2c_write(controlbyte);
   i2c_write(address>>8);     
   i2c_write(address);         
   i2c_write(data);           
   i2c_stop();
   // AckNolege pooling
   i2c_start();
   status=i2c_write(controlbyte);
   
   while(status==1)
   {
     i2c_start();
     status=i2c_write(controlbyte);
   }
   i2c_stop();
}

int8 readByte_24512x8(int32 memaddress){

    int16 address;
    int8  controlbyte;
    int8  data;

    address=memaddress;
    controlbyte=(0xa0 | ((make8(memaddress,2))<<1));

    i2c_start();
    i2c_write(controlbyte);
    i2c_write(address>>8);
    i2c_write(address);             
    i2c_start();
    i2c_write(controlbyte|1);
    data=i2c_read(0);
    i2c_stop();
    return data;
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 13, 2008 12:14 pm     Reply with quote

See the CCS FAQ:
http://www.ccsinfo.com/faq.php

See this article:
How do I write variables to EEPROM that are not a byte?
http://www.ccsinfo.com/faq.php?page=write_eeprom_not_byte
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