FM25C256

From MCS Wiki AVR
Revision as of 12:32, 24 August 2013 by Admin (Talk | contribs)
Jump to: navigation, search

The FM24C256 library is a library that uses a RAMTRON SPI 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. You can also increase the size of the EEPROM this way.

 

By using : $lib "fm25c256.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 FM25C256. It uses SPI

 

 

For the SPI you have to define the pins. The pin named fram_so is connected to SO of the FRAM. SI is connected to SI.

A sample is shown below. The clock and, cs and SI pins need to be configured as output pins.

 

Fram_cs Alias Portl.7 : Const Fram_csp = 7 : Const Fram_csport = Portl

Fram_so Alias Pind.1 : Const Fram_sop = 1 : Const Fram_soport = Pind

Fram_si Alias Portd.0 : Const Fram_sip = 0 : Const Fram_siport = Portd

Fram_sck Alias Portl.6 : Const Fram_sckp = 6 : Const Fram_sckport = Portl

 

Of course you can also use a cheaper normal SPI EEPROM. These are slower and have less write cycles.

 

Notice.jpg
This library is only included in the full version. It is not included with the DEMO.



Example

'-----------------------------------------------------------------------------------------
'name : 25C256 simple RW test.bas
'copyright : (c) 1995-2013, 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
 
 
 
' External EEPROM Config
Config Portb.4 = Output
Config Portb.7 = Output
Config Portb.5 = Output
Fram_cs Alias Portb.4 : Const Fram_csp = 4 : Const Fram_csport = Portb
Fram_so Alias Pinb.6 : Const Fram_sop = 6 : Const Fram_soport = Pinb
Fram_si Alias Portb.5 : Const Fram_sip = 5 : Const Fram_siport = Portb
Fram_sck Alias Portb.7 : Const Fram_sckp = 7 : Const Fram_sckport = Portb
 
$eepromsize = &H8000
$lib "fm25c256.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
'-------------------------------------------------------------------------------
Languages   English Deutsch  
 
Personal tools
Namespaces
Variants
Actions
Navigation
In other languages
Language