FM24C16

Top  Previous  Next

The FM24C16 library is a library that uses a RAMTRON I2C serial EEPROM.

Ramtron memory chips are as quick as RAM and can be overwritten almost unlimited times.

 

An external EEPROM is a safe alternative to the internal EEPROM.

 

By using : $lib "fm24c16.lib"

The EEPROM read and write routines from the library will be used instead of the internal EEPROM.

Thus you can still use : Dim BE as ERAM Byte

And you can use READEEPROM and WRITEEEPROM, but instead of using the internal EEPROM, the external I2C EEPROM is used.

The lib is for the FM24C16. It uses I2C/TWI.

 

 

noticeThis library is only included in the full version. It is not included with the DEMO.

 

Example

'-----------------------------------------------------------------------------------------
'name                     : 24C256 simple RW test.bas
'copyright                : (c) 1995-2021, MCS Electronics
'purpose                  : Testing Read/Write operation with external EEPROM
'micro                    : Mega8535
'suited for demo          : no
'commercial addon needed  : no
'-----------------------------------------------------------------------------------------
 
$regfile = "m8535.dat"                                     ' specify the used micro
$crystal = 8000000                                         ' used crystal frequency
$baud = 19200                                               ' use baud rate
$hwstack = 64                                               ' default use 32 for the hardware stack
$swstack = 20                                               ' default use 10 for the SW stack
$framesize = 40                                             ' default use 40 for the frame space
 
$lib "i2c_twi.lbx"                                         ' we do not use software emulated I2C but the TWI
 
Config Scl = Portc.0                                       ' we need to provide the SCL pin name
Config Sda = Portc.1                                       ' we need to provide the SDA pin name
 
I2cinit                                                     ' we need to set the pins in the proper state
 
Config Twi = 100000                                         ' wanted clock frequency
 
' External EEPROM Config
$eepromsize = &H8000
$lib "fm24c64_256.lib"
 
Dim A(101) As Eram Byte
Dim B As Byte
Dim C As Byte
Dim D As Byte
 
Do
  Input "Data to write ? (0-255)" , D
 
  Print "Reading content of EEPROM (via ERAM Byte)"
  For C = 0 To 100
     B = A(c)
    Print "Read ";C ; ":" ; B ; "/" ; Hex(b)
    Waitms 4
  Next
 
  Wait 1
 
  Print "Writing data to EEPROM (via ERAM Byte)"
  For C = 0 To 100
     A(c) = D
    Print "Write " ; C ; ":" ; D ; "/" ; Hex(d)
    Waitms 4
  Next
 
  Wait 1
 
  Print "Reading back data from EEPROM (via ERAM Byte)"
  For C = 0 To 100
     B = A(c)
    Print "Read " ; C ; ":" ; B ; "/" ; Hex(b)
    Waitms 4
  Next
 
  Wait 2
 
  Input "Data to write ? (0-255)" , D
 
  Print "Reading content of EEPROM (via READEEPROM)"
  For C = 0 To 100
    Readeeprom B , C
    Print "Read ";C ; ":" ; B ; "/" ; Hex(b)
    Waitms 4
  Next
 
  Wait 1
 
  Print "Writing data to EEPROM (via WRITEEEPROM)"
  For C = 0 To 100
    Writeeeprom D , C
    Print "Writing " ; C ; ":" ; D ; "/" ; Hex(d)
    Waitms 4
  Next
 
  Wait 1
 
  Print "Reading content of EEPROM (via READEEPROM)"
  For C = 0 To 100
    Readeeprom B , C
    Print "Read ";C ; ":" ; B ; "/" ; Hex(b)
    Waitms 4
  Next
 
  Wait 2
 
Loop
 
End
'-------------------------------------------------------------------------------