Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:45 11 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : FRAM on RTC module

Author Message
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 600
Posted: 02:55pm 21 May 2018
Copy link to clipboard 
Print this post

I have been going over all the work that was done here back in 2016
on using FRAM and started to get the basis of some of it.

Im looking at replacing the 24C32 on RTC modules with FRAM

At DigiKey

FM24V10 128K by 8 $12.76 A1 and A2 no A0
MB85RC1MT 128K by 8 $6.21 A1 and A2 no A0
MB85RC512T 64K by 8 $5.16
FM24V05 64K by 8 $12.64
MB85RC256V 32K by 8 $3.52
CY15B256J 32K by 8 $5.39

So the MB85RC1MT at $6.21 looks good.

Then the next thing hit me what if we could have something like

VARF save
VARF restore
VARF clear

basic thoughs going through my brain

function VARFS(v1,v2,v3,v1$,v2$,ect)
now how to get the names of the vars to be saved
(read some where here there is a way to get a pointer to the var's)
get total size of the var names and data
see if enough space to cont else error
memmap some thing like namevar1,sizevar1,datavar1,ect
address will start at 0 and go from there
write to FRAM (might loop write each namevar datavar) "255 byte $ limit ??"
end function

function VARFR
start adr at 0
read name,size,data
and now how to get data back into the var's
end function

function VARFC
erase FRAM 0 to last used
end function

probably faster as a C-Function (still going over writing C)

THANKS
Grogster
WhiteWizzard
twofingers
centrex
TassyJim

and all the other that added information to the topic.

Quazee
Edited by Quazee137 2018-05-23
 
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 600
Posted: 10:30pm 03 Jun 2018
Copy link to clipboard 
Print this post

Here's and update to where Im at with this
the basic idea


VARF "s","v1 w x$ y() z$()"
Print or test vs
VARF "r" restore if "r","w z$()" then selective restore
Print "varf status ";vs
VARF "c"
if vs then Print "error ";vs
-------------------------------

Sub VARF op$,myvar$
'test op$ for s,r,c
'extract var names from myvar$ ? I think only global vars are safe
'find in vartable
's=copy to FRAM vname,vsize,vdata
'r=copy from FRAM vdata
'c=clear FRAM
'0 no error
'if any errors save in vs
End Sub


learning the vartable


showvar.bas
'The showvar code is gleamed from TassyJim short array code. Thanks again for helping me to some what understand things.
'I am still trying to figure out the rest of the table
'the init code is ripped from my quad tower controller test.
'What I am trying to do is copy the var functionality to FRAM's.
'my test chip is 8k by 8 and on the DS3231 RTC module and that is 4 times the flash space of the 170
'later I will try the larger FRAM 128K by 8. Thats a lota storage for the 28 pin Mite. Still reading pdf

'OPTION COLOURCODE ON
'OPTION DISPLAY 24,132 easier to see it all

Option base 1
Option EXPLICIT

Dim test(2,2,2,2,2,2,2) length 2
'data arrays
Dim fn=100,r$(fn) length 1, f$(fn) length 1, d$(fn) length 4, s$(fn) length 4
Dim day$(fn) length 2
'runtime display vars
Dim rn$(4) length 9,dd$(4) length 4, ds$(4) length 4, df$(4) length 1
Dim c,count(4),fsc
'touch
Dim tx,ty,itx,ity,itx2,ity2,icx,icy,row,srow,col,penup=1,pendown=0
' mis keyboard vars "testing wip they cant decide which one to use"
Dim key$(45)=("1","2","3","4","5","6","7","8","9","0",".","q","w","e","r","t","y","u","i","o","p","*","a","s","d","f","g","h ","j","k","l",":","/","z","x","c","v","b","n","m","#","-","^","^"," ") length 1
Dim ar$(36)=("00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21"," 22","23","00","05","10","15","20","25","30","35","40","45","50","55")
Dim week$(35)=("Sun","Mon","Tue","Wed","Thr","Fri","Sat"," 1"," 2"," 3"," 4"," 5"," 6"," 7"," 8"," 9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28") length 3
Dim dy,mdow$(7) =("SUN","MON","TUE","WED","THR","FRI","SAT") length 3
'relay hardware pins and vars
Dim rstat(4) = (1,1,1,1) 'rstat stat 1=off 0=on
Dim relay(4) = (10,9,7,6) 'relay pins
Dim ry
'preset relays to off
For ry=1 To 4
' Pin(relay(ry)) = 1
' SetPin relay(ry),dout,oc
Next ry
' Flow switches
Dim FW12 = 4, FW34 = 5, P26 = 26
'flow switch status 1 = off 0 = on
' SetPin FW12, din
' SetPin FW34, din
' SetPin p26, ain

'just throw some values in them
tx=0:ty=8
itx=15:ity=16
itx2=63:ity2=64
icx=127:icy=128
row=5:srow=8:col=6

I2CScanner ' get a sub var test in here to show the locals here don't show

showvar ' but the ones here do
End

Sub clr
Print Chr$(27)+"[f" : Print Chr$(27)+"[2J"
End Sub

Sub locate x,y
Print Chr$(27)+"["+Str$(X)+";"+Str$(Y)+"f";
End Sub

'====================
Sub I2CScanner
Local found, i, temp
found=0
Print "I2C-Scanner from Adr. 8-119":Print:Print
For i = &h08 To &h77 ' gueltige I2C-Adressen von 8-119
I2C open 100, 1000 ' i2c enable 100kHz, 1000ms timeout
I2C read i, 0, 1, temp
' Print i;">"; MM.I2C " ";
If MM.I2C = 0 Then
Print:Print:Print "Found I2C-Address at "; i; " ("dec2hex$(i)+")"
found=1
EndIf
I2C close ' i2c disable
Next i
If found = 0 Then Print:Print:Print "NO I2C-Address found!"
End Sub

Function dec2hex$(number) ' used by I2C-Scanner
dec2hex$ = "&H"+ Hex$(number)
End Function

Sub showvar
Local g,n,p,ascii$,last=137

For g=0 To 63 'look through upto 64 variables
ascii$=""
For n = 0 To 31
p=Peek(VARTBL,n+g*64)
If p=0 Then Exit For 'build variable name (end at chr$(0))
Select Case Chr$(p)
Case "A" To "Z","0" To "9"
ascii$=ascii$+Chr$(p)
End Select
Next n
Print Str$(g,2);" ";ascii$;" ",

Print Hex$(Peek(VARTBL,32+g*64),2);" "; ' type 1 is number 2 is string not sure what anything else is
Print Hex$(Peek(VARTBL,33+g*64),2);" "; ' level sub / func ????
Print Hex$(Peek(VARTBL,35+g*64),2);Hex$(Peek(VARTBL,34+g*64),2);" "; ' looks like 8 levels of dimensions
Print Hex$(Peek(VARTBL,37+g*64),2);Hex$(Peek(VARTBL,36+g*64),2);" "; ' seems I can only use the 7 them ??
Print Hex$(Peek(VARTBL,39+g*64),2);Hex$(Peek(VARTBL,38+g*64),2);" ";
Print Hex$(Peek(VARTBL,41+g*64),2);Hex$(Peek(VARTBL,40+g*64),2);" ";
Print Hex$(Peek(VARTBL,43+g*64),2);Hex$(Peek(VARTBL,42+g*64),2);" ";
Print Hex$(Peek(VARTBL,45+g*64),2);Hex$(Peek(VARTBL,44+g*64),2);" ";
Print Hex$(Peek(VARTBL,47+g*64),2);Hex$(Peek(VARTBL,46+g*64),2);" ";
Print Hex$(Peek(VARTBL,49+g*64),2);Hex$(Peek(VARTBL,48+g*64),2);" ";

Print Hex$(Peek(VARTBL,50+g*64),2);" "; ' size ??

For n=51 To 55
Print Hex$(Peek(VARTBL,n+g*64),2);" ";
Next n
Print " ";
Print Hex$(Peek(VARTBL,59+g*64),2);Hex$(Peek(VARTBL,58+g*64),2);
Print Hex$(Peek(VARTBL,57+g*64),2);Hex$(Peek(VARTBL,56+g*64),2);" ";' little e address and/or ????
For n=60 To 63
Print Hex$(Peek(VARTBL,n+g*64),2);" ";
Next n
Print
If ascii$="LAST" Then Exit For
Next g

Print "test ";Hex$(Peek(VARADDR test()))
Print "fn ";Hex$(Peek(VARADDR fn))
Print "r$ ";Hex$(Peek(VARADDR r$()))
Print "rstat ";Hex$(Peek(VARADDR rstat()))
Print "relay ";Hex$(Peek(VARADDR relay()))
Print "last ";Hex$(Peek(VARADDR last))
End Sub


Can any one help with the vartable structure.

Thanks
Quazee



 
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 600
Posted: 03:16am 06 Jul 2018
Copy link to clipboard 
Print this post


OK here is the first part of my adventure with the FRAM

Getting the variable names passed to function


Print "1st part testing of varf concept "
Print " This part extracts the variable names to be use in the 2nd part."
Print " This is raw not cleaned up, just working concept"
Print " Code segments are from code by TassyJim, twofingers, Centrex"
Print " And many others on TBS. Thanks to every one!"
Print

Dim x As integer
'Im cheating here. As type is in the vartable already so no need to use
' or parse it here. But! may be better for code documentation if it is.
' could just strip them out before hand.

x= VARFS("a1,b,c,d4,e5,cats,z33,apples,b3,j,tbs,k")

Print x
' V
x=VARFS("a1,b,c,d4,e5,c-ats,z33,apples,b3,j,tbs,k")
Print x
' V
x=VARFS("a1,b,c,d4,e5,cats,z33,{apples,b3,j,tbs,k")

Print x
' V
x= VARFS("a1,b,c?,d4,e5,cats,z33,apples,b3,j,tbs,k")

Print x
' V
x=VARFS("a1,b,c,d4,e5,cats,z33,apples,b3,9j,tbs,k")

Print x
' V V
x=VARFS("a1,b,c,d4,e5,cats,z33,apples,b,j,tbs,k")

Print x

Print varfs("A,big,THANKS,to,all,at,the,back,shed")

Print "-----------------------------------------"


Function VARFS(a$)
Local INTEGER z,n,m,e

a$=UCase$(a$) ' the names in vartable are UPPER CASED
e=0
For z=1 To Len(a$)
If Mid$(a$,z,1)="," Then z=z+1
If Mid$(a$,z,1)< "0" Then e=1
If Mid$(a$,z,1)> "Z" Then e=2
If Mid$(a$,z,1)> "9" And Mid$(a$,z,1)<"A" Then e=3
Next z

If e<>0 Then
VARFS=e
Exit Function
End If

On ERROR SKIP 1' if SP$ doesn't exist, next line will cause an error
Erase SP$
z=1:n=0
Do 'count instances of delimiter for DIM SP$()
z=Instr(z,a$,",")
If z=0 Then
Exit Do
End If
n=n+1:z=z+1
Loop

m=n+1:n=1
Dim SP$(m)

Do
z=Instr(1,a$,",")
If z=0 Then SP$(m)=a$:Exit Do
SP$(n)=Left$(a$,z-1):a$=Mid$(a$,z+1)

e=Instr(1,"0123456789",Left$(sp$(n),1)) ' can't start with number

If e<>0 Then
VARFS=4
Exit Function
End If
n=n+1
Loop

For z=1 To m ' all var names are exclusve.
For n=1 To m
If z=n Then Exit For
If sp$(n)=sp$(z) Then e=5
Next n
Next z

If e<>0 Then
VARFS=e
Exit Function
End If

'testing to show sp$()
For z=1 To m
Print sp$(z);" ";
Next z
Print

End Function



Working on a fram hex editor for testing

and playing with the vartable dump test.

I have 8K,32K and 64K byte chips on RTC modules
the 128K is on the way.


 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025