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

EEPROM 93C56 16bit support

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
sv_shady



Joined: 07 Mar 2008
Posts: 28

View user's profile Send private message

EEPROM 93C56 16bit support
PostPosted: Tue Apr 29, 2008 12:25 pm     Reply with quote

This is an enhanced 9356.c file which supports EEPROM Disable Function and 16bit mode of organizing eeprom memory. It is extensively tested and it works fine.
Code:

#define EEPROM_SELECT PIN_C7
#define EEPROM_CLK    PIN_C6
#define EEPROM_DI     PIN_C5
#define EEPROM_DO     PIN_C4

#define EEPROM_SIZE    256

void Enable_ext_EEPROM()
{
   int cmd[2];
   int i;

   output_low(EEPROM_DI);
   output_low(EEPROM_CLK);
   output_low(EEPROM_SELECT);

   cmd[0]=0x80;
   cmd[1]=0x9;

   for(i=1;i<=4;++i)
      shift_left(cmd,2,0);
   output_high(EEPROM_SELECT);
   for(i=1;i<=12;++i)
   {
      output_bit(EEPROM_DI, shift_left(cmd,2,0));
      output_high(EEPROM_CLK);
      output_low(EEPROM_CLK);
   }
   output_low(EEPROM_DI);
   output_low(EEPROM_SELECT);
}

void Disable_ext_EEPROM()
{
   int cmd[2];
   int i;

   output_low(EEPROM_DI);
   output_low(EEPROM_CLK);
   output_low(EEPROM_SELECT);

   cmd[0]=0x00;
   cmd[1]=0x08;

   for(i=1;i<=4;++i)
      shift_left(cmd,2,0);
   output_high(EEPROM_SELECT);
   for(i=1;i<=12;++i)
   {
      output_bit(EEPROM_DI, shift_left(cmd,2,0));
      output_high(EEPROM_CLK);
      output_low(EEPROM_CLK);
   }
   output_low(EEPROM_DI);
   output_low(EEPROM_SELECT);
}


void write_ext_eeprom(int address, int data)
{
   int cmd[3];
   int i;

   cmd[0]=data;
   cmd[1]=address;
   cmd[2]=0xa;

   for(i=1;i<=4;++i)
      shift_left(cmd,3,0);
   output_high(EEPROM_SELECT);
   for(i=1;i<=20;++i)
   {
      output_bit(EEPROM_DI, shift_left(cmd,3,0));
      output_high(EEPROM_CLK);
      output_low(EEPROM_CLK);

   }
   output_low(EEPROM_DI);
   output_low(EEPROM_SELECT);
   delay_ms(11);
}

void write_ext_eeprom16(int address, int16 data)
{
   int16 cmd[2];
   int i, code;
    
    code = 0x05;
    cmd[0] = data;
   cmd[1] = make16(code, address);
   for(i=1;i<=5;++i)
      shift_left(cmd,4,0);
   output_high(EEPROM_SELECT);
   for(i=1;i<=27;++i)
   {
      output_bit(EEPROM_DI, shift_left(cmd,4,0));
      output_high(EEPROM_CLK);
      output_low(EEPROM_CLK);

   }
   output_low(EEPROM_DI);
   output_low(EEPROM_SELECT);
   delay_ms(11);
}
int read_ext_eeprom(int address)
{
   int cmd[3];
   int i,data;

   cmd[0]=0;
   cmd[1]=address;
   cmd[2]=0xc;

   for(i=1;i<=4;++i)
      shift_left(cmd,3,0);
   output_high(EEPROM_SELECT);
   for(i=1;i<=20;++i)
   {
      output_bit(EEPROM_DI, shift_left(cmd,3,0));
      output_high(EEPROM_CLK);
      output_low(EEPROM_CLK);
      if(i>12)
         shift_left(&data,1,input(EEPROM_DO));
   }
   output_low(EEPROM_SELECT);
   return(data);
}
int16 read_ext_eeprom16(int address)
{
   int16 cmd[2], data;
   int i, code;

   code = 0x06;
   cmd[0] = 0;
   cmd[1] = make16(code, address);
   
   for(i=1;i<=5;++i)
      shift_left(cmd,4,0);
   output_high(EEPROM_SELECT);
   for(i=1;i<=27;++i)
   {
      output_bit(EEPROM_DI, shift_left(cmd,4,0));
      output_high(EEPROM_CLK);
      output_low(EEPROM_CLK);
      if(i>11)
         shift_left(&data,2,input(EEPROM_DO));
   }
   output_low(EEPROM_SELECT);
   return(data);
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library 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