Action
Tell the compiler to use SPI memory as XRAM.
Syntax
$RAMTRON
Remarks
address |
The (hex)-address where the data is stored. Or the lowest address which enables the RAM chip. You can use this option when you want to run your code in systems with external RAM memory. |
Ramtron (www.ramtron.com) sell EEPROM's that are as fast as normal RAM chips.
They can be written billions of times. The $ramtron directive will use such as ramtron device as xram device. This only works for the AT89S8252. You only add a ramtron EEPROM to the hardware SPI lines and when you dim a variable as XRAM, the EEPROM will be used to store and retrieve the data.
This is a convenient way to add more memory without adding an address decoder and a RAM chip. Since the EEPROM is housed in a 8 pins chip it will make your design simple.
Note however that it is best practice that writing to such a XRAM variable must not be excessive. The data sheet of the Ramtron chips show that you can write it many times and in effect it will take years until you reach the limit.
Note that $RAMTRON does not need a parameter.
ASM
When XRAM is written with Movx @dptr,a , a call will be made to _WriteRamtron. Nothing is destroyed or returned.
When XRAM is read with Movx a,@dptr , a call will be made to _ReadRamtron. Value is returned in ACC as movx a,@dptr would do too.
Both routines are in the mcs.lib file. Both routines call _Wait_Spif to wait for the SPI, SPIF bit.
Example
'-------------------------------------------------------
' (c) 1995-2006 MCS Electronics
' RAMTRON.BAS
' This example shos how to use the www.ramtron.com eeprom
' to be used a XRAM
'-------------------------------------------------------
'it works only for the 8252
$regfile = "89s8252.dat"
'tell the compiler about ramtron
'THIS SAMPLE WILL NOT SIMULATE beause of the $RAMTON directive
'Suggestion is to add the directive when you simulated your program
$ramtron
'dim some variables
Dim X As Byte , X1 As Byte
'Now dim XRAM. This will be stored in the Ramtron devic
Dim Z(10) As Xram Byte
Wait 1
'I used P1.3 for the CS so the mcs.lib also uses this pin
'P1.4 could be used too but it needs a change in the mcs.lib
'This sample works actually!
'But since I also have code like *+4 it will not work always
'I need to rewrite that code. Let me know when some routines dont work
'with the $ramtron directive
'fill the data
For X = 1 To 10
Z(x) = X
Next
'print the data
For X = 1 To 10
Print Z(x)
Next
End