Pic16F628A and 24LC256 EEPROM I2C


Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Nov 2005
    Location
    US
    Posts
    4

    Arrow Pic16F628A and 24LC256 EEPROM I2C

    Is this hookup valid for I2C EEPROM storage of data?
    (see .JPG file)
    First EEPROM is Address $00 and the other Address $01

    Part of PicBASIC Pro program follows:

    ' **********************************************
    ' Using PIC16F628A and 24LC256 EEPROMs
    ' **********************************************
    SCLK VAR PORTB.6 ' Data Pin on I2C
    SDATA VAR PORTB.7 ' Clock Pin on I2C
    addr VAR WORD ' Memory location in EEPROM to use
    CntRec VAR WORD ' Value of count to store in EEPROM

    addr = %00000001 ' Location of memory to use
    CMCON = 7 ' PORTA digital

    ' if power is applied, want last count of data stored in EEPROM -
    ' Read EEPROM first to get last count

    I2CREAD SDATA,SCLK,$A0,addr,[CntRec]

    GOSUB LCD_Display01 : Display count from EEPROM
    ' Send CntRec out to Serial bus or LCD Display to display content

    Main:
    If DET_IN = 1 THEN ' any form of detector circuit
    CntRec = CntRec + 1 ' Increment count in EEPROM
    GOSUB LCD_Display01
    IF CntRec >= 255 THEN
    CntRec = 1
    GOSUB LCD_Display04 ' reset count
    EndIf
    EndIf

    I2CWRITE SDATA,SCLK,$A0,addr,[CntRec] ' Write new count

    GOTO Main ' continuous loop ....

    LCD_Display01:
    LCDOUT CMD, Line1, "* * * * * * * Detected Signal * * * * *"
    LCDOUT CMD, Line2, " Detect Total = " ,#CntRec, " "
    RETURN

    LCD_Display04:
    LCDOUT CMD, Line1, "* * * * * * * Reset Count * * * * * * *"
    LCDOUT CMD, Line2, " EEPROM = " ,#CntRec, " "
    PAUSE 5000 ' pause for 5 seconds
    RETURN
    Attached Images Attached Images  

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts