EX_EXTEE.C  



I2C EEPROM 24LC02 EXAMPLE

/////////////////////////////////////////////////////////////////////////
////                          EX_EXTEE.C                             ////
////                                                                 ////
////  This program uses the 24xx or 93xx external EEPROM drivers to  ////
////  read and write to an external serial EEPROM.                z  ////
////                                                                 ////
////  Change the #include <9356.C> to any of the other drivers to    ////
////  test other parts.  Note each driver defines EEPROM_ADDRESS     ////
////  indicate 8 or 16 bit addresses.                                ////
////                                                                 ////
////        (C) Copyright 1996,1997 Custom Computer Services         ////
////                                                                 ////
/////////////////////////////////////////////////////////////////////////

#include <16F84.H>
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_A3, rcv=PIN_A2)

#include 
#include <2402.C>


main() {

   byte value,cmd;
   EEPROM_ADDRESS address;

   init_ext_eeprom();

   do {
      do {
         printf("\r\nRead or Write: ");
         cmd=getc();
         cmd=toupper(cmd);
         putc(cmd);
      } while ( (cmd!='R') && (cmd!='W') );

      printf("\n\rLocation: ");

#if sizeof(EEPROM_ADDRESS)==1
      address = gethex();
#else
#if EEPROM_SIZE>0xfff
      address = gethex();
#else
      address = gethex1();
#endif
      address = (address<<8)+gethex();
#endif

      if(cmd=='R')
         printf("\r\nValue: %X\r\n",READ_EXT_EEPROM( address ) );

      if(cmd=='W') {
         printf("\r\nNew value: ");
         value = gethex();
         printf("\n\r");
         WRITE_EXT_EEPROM( address, value );
      }
   } while (TRUE);

}


Navigation Bar

tech_support@blitzlogic.com