View previous topic :: View next topic |
Author |
Message |
gertc
Joined: 06 May 2006 Posts: 88
|
Posted: Sun Jul 26, 2015 4:04 am Post subject: EEPROM being erased when programming |
|
|
Hello,
I wrote a program where I am storing data in the eeprom. It takes about 10 minutes to do the inital setup where I am storing lot of data in the eeprom, that is loaded everytime the cpu is powered up. Under normal operation this is fine, but in the development stage I want to keep the setup data in the eeprom, when I am downloading a modified code.
The problem is that the eeprom get erased every time I reprogram the cpu, and now have to spend 10 minutes again for the setup.
In the Programmer option screen, the check box "Upload Code and Data" is un-checked. Are there a fault in the bascom program, or what am I doing wrong?
Thanks,
gertc
Here is a simplified code:
Code: | $regfile = "attiny167.dat" 'Microprocessor Type
$crystal = 8000000 ' Frequency 16Mhz
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space
Config Pina.5 = Input
Dim Sp_th_eram As Eram Integer At 112 ''(70h)
Dim Sp_ma_eram As Eram Integer At 128 ''(80h)
Dim Sp_th As Integer
Dim Sp_ma As Integer
'---------------------------------------------------------------------------
'ADC
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Start Adc
'---------------------------------------------------------------------------
'PROGRAM
Sp_th = Sp_th_eram ' Read 1st eeprom address after power-up (112, 70h)
Sp_ma = Sp_ma_eram ' Read 2nd eeprom address after power-up (128, 80h)
Do
'Code
'.
'.
If Pina.5 = 0 Then
Gosub Setup_routine
End If
'Code
'.
'.
Loop
Setup_routine:
Sp_th = Getadc(0)
Sp_ma = Getadc(1)
Sp_th_eram = Sp_th 'Store new value in eeprom
Sp_ma_eram = Sp_ma 'Store new value in eeprom
Return |
(BASCOM-AVR version : 2.0.7.7 , Latest : 2.0.7.8 ) |
|
Back to top |
|
|
Deanus
Joined: 26 May 2006 Posts: 188 Location: Adelaide
|
Posted: Sun Jul 26, 2015 6:39 am Post subject: |
|
|
Hi gertc,
See $EEPLEAVE in the help file
Dean |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Sun Jul 26, 2015 8:17 am Post subject: |
|
|
Hi,
Also check the lock and fuse bits. There's a fuse "EESAVE" - EEPROM memory is preserved through the Chip Erase and this Defaults to not programmed (EEPROM will not be preserved on Flash erase).
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
gertc
Joined: 06 May 2006 Posts: 88
|
Posted: Tue Jul 28, 2015 2:11 am Post subject: |
|
|
Thanks for the suggestions.
I changed Fusebit "H" to [0: Preserve EEPOM trough Chip Erase] . That was excatly what I needed.
Thanks again,
gertc |
|
Back to top |
|
|
|