View previous topic :: View next topic |
Author |
Message |
Inventor-George
Joined: 28 Mar 2006 Posts: 74
|
Posted: Fri Mar 24, 2017 5:24 pm Post subject: Storing word variables in Xmega EEPROM |
|
|
I am using the xmega128A4U device.
I need to store over a hundred word variables in eeprom.
I can't find anything about this in the help files. Do I have to split the word into two bytes, store in two separate EEPROM locations, then upon reading it back, reassemble it into a word? Seems a very slow way to handle stored variables.
Is there any faster way to handle this? I need to do this as efficiently [time-wise] as possible.
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Fri Mar 24, 2017 8:02 pm Post subject: |
|
|
Hi George,
Something like this:
Code: |
Config Eeprom = Mapped
Dim Myword1 As Eram Word
Dim Myword2 As Eram Word
Dim Myword3 As Eram Word
|
_________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
Inventor-George
Joined: 28 Mar 2006 Posts: 74
|
Posted: Fri Mar 24, 2017 11:50 pm Post subject: |
|
|
HI Evert:
I tried this:
Dim myword1 As Eram Word
Dim myword2 As Eram Word
myword1 = 33123
writeeeprom myword1, 10
readeeprom myword2, 10
lcd myword2
I get the following errors
Error : 253 Line : 41 ERAM variable can not be used [MYWORD2] , in File : J:\Current Business\____Projects\_57 - Phone Hearing Loss\Prototype\Code\Xmega128A4U code - ver A1B.bas
Error : 42 Line : 42 Numeric parameter expected [MYWORD2] , in File : J:\Current Business\____Projects\_57 - Phone Hearing Loss\Prototype\Code\Xmega128A4U code - ver A1B.bas
Thoughts? |
|
Back to top |
|
|
Inventor-George
Joined: 28 Mar 2006 Posts: 74
|
Posted: Sat Mar 25, 2017 12:15 am Post subject: |
|
|
I figured out how to handle this. Thank you! It works.
To save to Eeprom, do I simply set address for every OTHER location? Like location 2,4,6,8? |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Sat Mar 25, 2017 11:27 am Post subject: |
|
|
forget about writeeeprom and readeeprom.
There is no need to know the address in memory.
Code: | Dim Ar(10) As Eram Word
Dim W As Word
Dim J As Byte
For J = 1 To 10
W = J
Ar(j) = W
Next
For J = 1 To 10
W = Ar(j)
Print W
Next
|
A word will use 2 bytes automatic.
Just remember : you need to use an SRAM variable to read/write to an ERAM variable. and they must be of the same data type. _________________ Mark |
|
Back to top |
|
|
|