View previous topic :: View next topic |
Author |
Message |
sidknox
Joined: 30 Apr 2006 Posts: 29 Location: NorthEast Oklahoma USA
|
Posted: Fri May 23, 2014 6:34 am Post subject: Using Internal EEPROM |
|
|
I need to store some variable data in internal eeprom.
I wrote this simple program to refresh my brain on how to do it.
It runs ok and displays "1 2 3" on the LCD as expected.
Opening the Programmer window and selecting the "EEPROM" tab, I see &h0B, &h0C, &h0D (11, 12, 13) in locations 00, 01, 02 as expected from the $eeprom assignments.
I am expecting to see 01, 02, 03 at locations &h10, &h11, &h12 (16, 17, 18) where the eeprom pointer points but they each show &hFF as does every other eeprom location.
But... if I compile and run the same code in the Simulator, "1 2 3" shows on the simulator's LCD and the Simulators
Memory window shows both the $eeprom data as before *and* the variable data in locations &h10, &h11, &h12 where I expect it to be.
So, the question is: When running the code in the mega32, why does it read the eeprom and display the variable data properly but this data does not show in the "EEPROM" tab in the Programmer window?
**********************************************************************
'-----------[ Title ]----------------------------------------------------------
' Filename : eeprom_forum.bas
' Purpose : test to store and retrieve data from internal eeprom
' Author : sid knox
' Date : 23 May 2014
' Compiler : BASCOM-AVR Rev. 2.0.7.1
'
'-----------[ Algorithm ]------------------------------------------------------
'
'example of writing to and reading from internal eeprom. also, use of $eeprom
' to store comstant DATA values in internal eeprom.
'
'-----------[ Hardware ]-------------------------------------------------------
'
'Futurlec ere.co.th mega32 dev board with DS1307 RTC and 24C65 EEPROM.
' (neither used in this program).
'LED on porta.7
'LCD on portc
'
'-----------[ Options/Compiler/Chip ]------------------------------------------
'
' Setup for Mega32
' HW Stack 48
' Soft Stack 32
' Framesize 64
' Programmer: USBASP
' Programmer options: code and data
'-----------[ Declarations` Defines` Dims, Configs, etc.. ]--------------------
'
$regfile = "m32def.dat"
$crystal = 16000000 '16 MHz ext xtal
$sim
$hwstack = 48
$swstack = 32
$framesize = 64
Dim bytPointer as Byte
Dim bytB1 As Byte , bytB2 As Byte , bytB3 As Byte
Dim bytB4 As Byte , bytB5 As Byte , bytB6 As Byte
'Config Porta.7 = Output 'LED
Config PortC = Output 'LCD
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = Portc.6 , _
Db7 = Portc.7 , E = Portc.3 , Rs = Portc.2
Config Lcd = 20 * 2
Cursor Off
'---[ Initialization ]---------------------------------------------------------
'
bytB1 = 1
bytB2 = 2
bytB3 = 3
'
'---[ Main program, no loop, runs one time only ]------------------------------
cls
Lcd "eeprom forum"
wait 2
cls
'now,write some data to eeprom
bytPointer = 16 'assign pointer
WriteEeprom bytB1 , bytPointer
Incr bytPointer 'increment pointer
WriteEeprom bytB2 , bytPointer
Incr bytPointer 'increment pointer
WriteEeprom bytB3 , bytPointer
'now,read the data in eeprom and show on LCD
bytPointer = 16 'reset pointer
ReadEeprom bytB4 , bytPointer
Lcd bytB4 ; " ";
Incr bytPointer
ReadEeprom bytB5 , bytPointer
Lcd bytB5 ; " ";
Incr bytPointer
ReadEeprom bytB6 , bytPointer
Lcd bytB6 ; " "
'Load some data into eeprom (not used elswhere, test only)
$eeprom
Dta:
Data 11 , 12 , 13
end
'#######################[ THE END ]####################
[b][color=red](BASCOM-AVR version : 2.0.7.1 , Latest : 2.0.7.7 )[/b][/color] _________________ SidK
Oklahoma
USA |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
Posted: Fri May 23, 2014 8:15 am Post subject: |
|
|
$EEPROM generate separate file for program chip eeprom.
http://wiki.mcselec.com/bavr/$EEPROM
Maybe this depends on the programmer you use to automatical load eeprom content to it.
After compile I see eep.eep file in project folder and 0B,0C,0D at 00000000 as expected.
I know some Parameter can be added to options of programmer for one of my programs.
If I add this in options: {FILE} {CHIP} /AS /CE then: programmer automaticaly Identify chip type,AS - autostart, CE - close on exit |
|
Back to top |
|
|
Evert :-)
Joined: 18 Feb 2005 Posts: 2156
|
Posted: Fri May 23, 2014 9:16 am Post subject: Re: Using Internal EEPROM |
|
|
sidknox wrote: |
Opening the Programmer window and selecting the "EEPROM" tab, I see &h0B, &h0C, &h0D (11, 12, 13) in locations 00, 01, 02 as expected from the $eeprom assignments.
I am expecting to see 01, 02, 03 at locations &h10, &h11, &h12 (16, 17, 1 where the eeprom pointer points but they each show &hFF as does every other eeprom location.
|
What you see in the eeprom programmer window is the content created by the Bascom compiler, and not what's changed during run time. Your locations 16,17,18 are changed during run time.
If you want to see the altered content of the eeprom you need you read the content back from the avr.
To say it simple, press the read eeprom in to buffer button in the eeprom programmer window. _________________ www.evertdekker.com Bascom code vault |
|
Back to top |
|
|
sidknox
Joined: 30 Apr 2006 Posts: 29 Location: NorthEast Oklahoma USA
|
Posted: Fri May 23, 2014 5:17 pm Post subject: Using Internal EEPROM |
|
|
Yes Evert!! That is what I was missing. I had seen that tab but mistakenly assumed that it was for code only.
Thank you very much!!
Sid _________________ SidK
Oklahoma
USA |
|
Back to top |
|
|
|
|
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
|
|