Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

EEProm problem

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
svberg

Bascom Member



Joined: 07 Nov 2011
Posts: 48

blank.gif
PostPosted: Thu Oct 21, 2021 9:35 am    Post subject: EEProm problem Reply with quote

Hi.
Have a strange problem. Need to set some default values in EEprom, but one byte is failing.
I'm doing this;
zb=0
xi=50
Writeeeprom zb,xi '"0" Key OFF
incr xi
zb=1
Writeeeprom zb,xi '"1" Key On Board
incr xi
Writeeeprom zb,xi '"1" Key On Route
incr xi
zb=0
Writeeeprom zb,xi '"0" Key On Shore
incr xi
zb=20
Writeeeprom zb,xi '"20" Current limit at 20A
incr xi
zb=1
Writeeeprom zb,xi '"1" Limit type Normal
incr xi
zb=1
Writeeeprom zb,xi '"1" Lock down

I then read back the content of the EEprom, both with the programmer, and in my program, everything is fine, except the line Limit Type Normal.. There I read the hex byte 31 which is 49 des. and asc 1.
WHY, WHY???
Anybody encountered something like this??

Using Bascom 2.0.8.4 with ATMEGA2560. Programming with Arduino STK500V2.

(BASCOM-AVR version : 2.0.8.4 )
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Thu Oct 21, 2021 10:25 am    Post subject: Reply with quote

TYPE is a reserved word.
you better not use it.

instead of Writeeeprom you can best use the pseudo variable ERAM. Much simpler. See help : DIM var as ERAM byte

if you can not solve the problem you should show a small sample that we can actual test, thus including $regfile, etc.

_________________
Mark
Back to top
View user's profile Visit poster's website
Paulvk

Bascom Member



Joined: 28 Jul 2006
Posts: 1257
Location: SYDNEY

australia.gif
PostPosted: Fri Oct 22, 2021 1:51 am    Post subject: Reply with quote

I use a Eram Array for such variables.
This makes it easy to read the default as it is a variable.

If you are use to Arduino code you have to read more of Bascom's help
because Bascom does a lot of the work for you it has very powerful functions
that Arduino does not , two of note are the Split function and the Overlay

I have been programming ESP8266 with Arduino and with what I can
do with one command in Bascom takes a dozen lines of code with Arduino

RegardsPaul

Code:


 
 Dim Defaults(10) As Eram Byte
 Dim A As Byte
 Dim B As Byte

 A = 0                                                      'Key OFF
 Defaults(1) = A

 A = 1                                                      'Key On Board
 Defaults(2) = A

 A = 1                                                      'Key On Route
 Defaults(3) = A

 A = 0                                                      'Key On Shore
 Defaults(4) = A

 A = 20                                                     'Current Limit at 20A
 Defaults(5) = A

 A = 1                                                      'Limit type Normal
 Defaults(6) = A

 A = 1                                                      'Lock down
 Defaults(7) = A


  'Now to find the current limit

  B = Defaults(5)

  ' variable B now will have the value of 20



 
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum