Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
jgmdesign
PostPosted: Jan 28, 2012 - 01:55 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

I see in the programming section a way to preload information into the eeprom space. I believe it is looking for an .elf file. Anyone suggest a for dummies paper on how this is done?


Jim

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
david.prentice
PostPosted: Jan 28, 2012 - 02:05 PM
10k+ Postman


Joined: Feb 12, 2005
Posts: 16329
Location: Wormshill, England

Use file.EEP or file.ELF

You can put any HEX file into the EEPROM if it fits.

All that you are really worrying about is that you should not erase the chip when you program the FLASH.

In practice, you would either:

1. Erase, program flash, program eeprom

or:

1. Erase
2. program eeprom
3. program flash

or:

1. set EESAVE fuse
2. erase and program flash or eeprom in any order you like

You can either put all the operations into an avrdude.exe, stk500.exe, ... command (or batch file)
Or put all the operations into a single ELF file

The EESAVE method seems the most foolproof method.

David.
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
jgmdesign
PostPosted: Jan 28, 2012 - 02:18 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

Well, the project I am trying to finish is itting on the bench with debugwire from the dragon connected to the M48.
So right now I would like to load that up during debugging. After that I will be loading everything either through stk500 or ISPMKII.

What is the format for the .eep/.elf file? Is it something I can create in excel or notepad and change the extension to .elf or .eep?


Jim

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
david.prentice
PostPosted: Jan 28, 2012 - 02:47 PM
10k+ Postman


Joined: Feb 12, 2005
Posts: 16329
Location: Wormshill, England

An EEP file is exactly the same as a HEX file. It is only a convention that you keep the two files together by sharing a name.

You can write an ELF file with GCC. I doubt that many other toolsets support the 'fuses' aspect of it.

You can also construct a production ELF file from the constituent eeprom, flash, fuses, lock in Studio4. It is a lot of faffing about.

Surely you just set EESAVE fuse and go. It must be the easiest method.

If your application has some initialised __eeprom data, the debugger will read this in regardless.

Personally, I never use initialised __eeprom. I read the existing contents, determine whether virginal, and the application writes any initial data.

Subsequent runs use the non-virginal data.

David.
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
jgmdesign
PostPosted: Jan 28, 2012 - 03:07 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

??GCC?? Nevermind. I'll figure something else out. GCC is not simple for me to grasp. I would not even know where to start just to create a simple file to load into the eeprom.

Thanks David,
Jim

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jan 28, 2012 - 03:19 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62363
Location: (using avr-gcc in) Finchingfield, Essex, England

You can generate a .eep in AS4/5 Asm just as easily:
Code:
.eseg

.db 1,2,3,4,5

Assemble that and it will generate a .eep file (intel hex by the way) that will load 1,2,3,4,5 into the first 5 EEPROM locations when you use ISP to program it.

If you have existing Asm code then just tag that onto the end and when you build you will get both a .hex as usual with the code and a .eep with those 5 bytes. Also, if you "start debugging" using either simulator or debug interface Studio will say "this project has EEPROM data do you want to load it now?"

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
jgmdesign
PostPosted: Jan 28, 2012 - 03:44 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

Hmmmmm
Cliff,
Can I do something like this?

Code:
.eseg
<NAME>        .db 1,2,3,4,5,6,7,8,9,10


THEN,
In code issue an eeprom read starting at <NAME> and reading the ten bytes?

Jim

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jan 28, 2012 - 03:49 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62363
Location: (using avr-gcc in) Finchingfield, Essex, England

yes, that's what you'd normally do. In fact you could do:
Code:
.cseg

EEPROM_read:
  ; Wait for completion of previous write
  sbic EECR,EEWE
  rjmp EEPROM_read
  ; Set up address (r18:r17) in address register
  out  EEARH, r18
  out  EEARL, r17
  ; Start eeprom read by writing EERE
  sbi  EECR,EERE
  ; Read data from data register
  in  r16,EEDR
  ret

main:
  ldi r17,low(bar)
  ldi r18,high(bar)
  call EEPROM_read

.eseg
foo: .db 37
bar: .db 51

(EEPROM code lifted from mega16 datasheet)

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
jgmdesign
PostPosted: Jan 28, 2012 - 04:05 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

Hmmmmmm again,
The prewrite is strictly a debugging need. THe final is a string that is stored at run time and really will never be changed.

Right now I want the eeprom to store the following:

Code:

.eseg
myname:       .db j,g,m,d,e,s,i,g,n,s


Then in the code to read this into a SRAM location for use later on.

Jim

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
david.prentice
PostPosted: Jan 28, 2012 - 04:20 PM
10k+ Postman


Joined: Feb 12, 2005
Posts: 16329
Location: Wormshill, England

Code:
.eseg
myname:       .db j,g,m,d,e,s,i,g,n,s


Dependng on your assembler, you can use:
Code:
.eseg
myname:       .db "jgmdesigns"

or
Code:
.eseg
myname:       .db 'j','g','m','d','e','s','i','g','n','s'


You will write a subroutine that takes an eeprom address location as a parameter and returns the value.

You will have a corresponding one that writes a value to the location.

Write once. Document once. Use many times.

David.
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
jgmdesign
PostPosted: Jan 28, 2012 - 05:44 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

David,
I am using studio 4's assembler. I only fired my code up the way I did to be quick. Bad move.

I was hoping to put this in:
Code:
.eseg
myname:       .db "jgmdesigns"



It should work as I can do this in .cseg when I am doing an LMP instuction.

the proof in the pudding is to do it and see what happens

Jim

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
david.prentice
PostPosted: Jan 28, 2012 - 06:06 PM
10k+ Postman


Joined: Feb 12, 2005
Posts: 16329
Location: Wormshill, England

Cliff has given you an example subroutine.

Neither he nor I have any idea of your coding style. So we do not know whether you pass subroutine parameters on the stack, in registers, in sandwiches, ...

And which registers you may use or trash.

The basic principles are exactly the same whatever language you use. The details are up to you. e.g.
1. read the 'name' contents from the eeprom.
2. if it says "jgmdesigns" then virginal.
3. write your application data.

I thought that you used Bascom. They will already have the necessary functions for this, and your life would be simple.

Remember to tick the EESAVE checkbox.

David.
 
 View user's profile Send private message Send e-mail  
Reply with quote Back to top
jgmdesign
PostPosted: Jan 28, 2012 - 08:01 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

No problem David, I run EVERYTHING is Studio since it never makes mistakes Wink

Here is what I threw together:
Code:


.include "m48pdef.inc"

.eseg
eserial:      .db "jgmdesigns"
eaddr:         .byte  1


.dseg
serial:         .byte 10
addr:         .byte  1
rxbuffer:      .byte 13


.cseg

jym:      rjmp   jym


It assembled just fine, but when I fired up the simulator and single stepped it twice, the EEPROM watch window shows it blank. I would have figured even with the code so simple it would have loaded the eeprom with jgmdesigns, but nope.

Will look into this some more. That should have worked in my book no?

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
jgmdesign
PostPosted: Jan 28, 2012 - 08:09 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

Figured it out
Had to load the eeprom from file after starting the debugger/simulator.

Makes sense.

Gonna work on this some more later....Right now the little one wants to play

Thanks guys

Jim

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
js
PostPosted: Jan 28, 2012 - 09:53 PM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20392
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

Quote:
Had to load the eeprom from file after starting the debugger/simulator.
... with "up\download file".

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jgmdesign
PostPosted: Jan 28, 2012 - 10:56 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

Quote:
... with "up\download file".


Wink

Yeah I took my own, as well as the common advice given around here....RTFM


Jim

EDIT: THe funky part is that when you do the upload/download an error/warning that the size of the file is to big for the eeprom. It then cuts the file down to the size of the bytes I want loaded. If you don't know to kinda ignore the notice it could throw you off. Just an observation

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
khemchicken
PostPosted: Jan 29, 2012 - 12:07 AM
Newbie


Joined: Jan 29, 2012
Posts: 1


Thank you for this article. That’s all I can say. You most definitely have made this post into something special. You clearly know what you are doing, you’ve covered so many bases.Thanks!





The operatorคาสิโนออนไลน์ around the world will work to establish the Union คาสิโนออนไลน์, the world soon. We are looking for members


Last edited by khemchicken on Jan 31, 2012 - 12:38 PM; edited 1 time in total
 
 View user's profile Send private message  
Reply with quote Back to top
jgmdesign
PostPosted: Jan 29, 2012 - 01:25 AM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

On behalf of the other juvenile delinquents who have posted above

THANK YOU!!

Quote:
You most definitely have made this post into something special.


Hey guys, we need to frame this on the home page! Smile

JIm

P.S. Khemchicken, WELCOME ABOARD

ok,
As it turns out loading the eeprom helped make sure other parts of the code behaved without having to setup the dragon, wire a breadboard etc. Good to know. Iusually plod through with wiring up the dragon and a breadboard. THis way saves the hassle. Lets you check behaivior before wiring it all up and then roll the dice.
Learn sumtin' new every day

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: Jan 29, 2012 - 01:31 AM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

jgmdesign wrote:
On behalf of the other juvenile delinquents who have posted above

THANK YOU!!

Quote:
You most definitely have made this post into something special.


Hey guys, we need to frame this on the home page! Smile

JIm

P.S. Khemchicken, WELCOME ABOARD
Don't you think that talking to a spam bot and greeting him requires an immediate visit to your doctor? Laughing
 
 View user's profile Send private message  
Reply with quote Back to top
js
PostPosted: Jan 29, 2012 - 02:04 AM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20392
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

Quote:
talking to a spam bot
I was about to delete the post as it smells spammish, but there isn't any links or anything else harmful. So in the spirit of "Perestroika" I'm givng it the benefit of the doubt. Smile

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jgmdesign
PostPosted: Jan 29, 2012 - 03:45 AM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

@MBedder....

I LOVE spam....It tastes great on a saltine.

I had a feeling the post was not on the up and up, but since Cliff lashed out at everyone about being jerks at noob posts I decided to give the benefit of the doubt...just not too seriously...THat's why I put the following in a quote
Quote:
Quote:
You most definitely have made this post into something special.


Hey guys, we need to frame this on the home page!


At least my P.S was ot bullcrap.

Oh well, mother was right...cannot please anyone these days

Jim

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jan 29, 2012 - 12:41 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62363
Location: (using avr-gcc in) Finchingfield, Essex, England

It's spam - I imagine it was supposed to be signature spam but the bozo forgot to turn it on.

(actually it could be cleverer than that - he has no current signature assigned, so he posts a few of these seemingly innocuous posts then later comes back and sets a URL into the signature in his profile)

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
jgmdesign
PostPosted: Jan 29, 2012 - 08:55 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

Ok then, back to the topic....sort of
I put this into my equates section:

Code:
.equ   rst      ="R"


The intent is that when the m48 sees the ascii number for the letter R come in on the uart it knows what to do. I personally don't want to have to keep looking up ascii codes

Thought this would have worked like the eeprom load but nope. tried a few variations with no luck

jim

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jan 29, 2012 - 09:05 PM
10k+ Postman


Joined: Jul 18, 2005
Posts: 62363
Location: (using avr-gcc in) Finchingfield, Essex, England

'R' not "R" surely?

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
jgmdesign
PostPosted: Jan 29, 2012 - 09:24 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

Yes I did write "R" as I was going off the .db"JGMDESIGNS" convention earlier discussed. Figured the "" would denote ascii not ''

Jim

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
js
PostPosted: Jan 29, 2012 - 09:57 PM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20392
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

Single character=single '
More than 1 character or string = double "
..as Cliff pointed out.

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jgmdesign
PostPosted: Jan 29, 2012 - 10:24 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

Quote:
..as Cliff pointed out.

Did not quite see Cliffs point intill you "POINTED" it out Smile

Jim

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
jgmdesign
PostPosted: Jan 30, 2012 - 10:06 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

Well things are getting to the end. I cpoied the write and read routines out of the datasheet to load the eeprom, and then tou read it back and output it to the terminal program, but no good:

Code:
Write_eeprom:
      ldi      ZH,high(wait*2)   ;Inform operator to wait for eeprom write
      ldi      ZL,low(wait*2)
      rcall   messsend
;write 10digit unique ID to eeprom
      ldi      XH,0x00      ;load eeprom pointer with eserial location
      ldi      XL,(eserial)
      ldi      YH,high(dserial)      ;load sram pointer with dserial location
      ldi      YL,LOW(dserial)
EEPROM_write:
      ld      temp,Y+
; Wait for completion of previous write
      sbic    EECR,EEPE
      rjmp    EEPROM_write
; Set up address (xreg) in address register
      sts      EEARL, XL
; Write data (r16) to Data Register
      sts    EEDR,temp
; Write logical one to EEMPE
      sbi    EECR,EEMPE
; Start eeprom write by setting EEPE
      sbi    EECR,EEPE
      cpi      YL,0x0d      ;last byte
      breq   ewrtdone
      inc      XL
      rjmp    EEPROM_write
ewrtdone:
      ldi      ZH,high(cmpltwr*2)   ;Inform operator eeprom Write complete
      ldi      ZL,low(cmpltwr*2)
      rcall   messsend
      
;readback eeprom
ldi   XL,(eserial)
EEPROM_read:
; Wait for completion of previous write
sbic EECR,EEPE
rjmp EEPROM_read
; Set up address (xreg) in address register

sts EEARL, XL
; Start eeprom read by writing EERE
sbi EECR,EERE
; Read data from Data Register
in temp,EEDR   
rcall   bytesend
cpi      XL,0x0d
breq   end
inc      XL
rjmp   eeprom_read   
end:      rjmp   end


The terminal behaves like the avr is programming, bt when I ask it to read back no go. Tried to connect up the dragon to have a look inside but with the m48 in the stk500 it won't connect(yes I removed the reset jumper)

I am more interested in the eeprom than the dragon.

Any ideas?

Jim

Edit: I used "STS" aas opposed to "OUT" like in the example because the assembler spit up with an error. I have seen this before so I use STS instead. Works though

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
js
PostPosted: Jan 30, 2012 - 10:21 PM
10k+ Postman


Joined: Mar 28, 2001
Posts: 20392
Location: Sydney, Australia (Gum trees, Koalas and Kangaroos, No Edelweiss)

Code:
EEPROM_write:
      ld      temp,Y+
; Wait for completion of previous write
      sbic    EECR,EEPE
      rjmp    EEPROM_write
In the time one EEPROM byte is written (a few ms), Y will be pointing to outer space. Smile

Maybe this will fix it, there maybe other stuff I can't see.
Code:
EEPROM_write:
      ld      temp,Y+
; Wait for completion of previous write
EEPROM_write_loop:
      sbic    EECR,EEPE
      rjmp    EEPROM_write_loop


edit
Quote:
I used "STS" aas opposed to "OUT"
Start using the AVR001 macros, it will select the correct instructions for you.

_________________
John Samperi
Ampertronics Pty. Ltd.
www.ampertronics.com.au
* Electronic Design * Custom Products * Contract Assembly


Last edited by js on Jan 30, 2012 - 10:29 PM; edited 1 time in total
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
jgmdesign
PostPosted: Jan 30, 2012 - 10:28 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

OHHHHHHHHHHHHHHHH FU#$% Sad

This is what happens when you stare at this crap too long!

Thanks King Samperi

Jim

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
jgmdesign
PostPosted: Jan 30, 2012 - 10:32 PM
Raving lunatic


Joined: Apr 20, 2007
Posts: 6078
Location: Long Island New York

Well, that was fixed, but when I read back I get <0>

gonna look for another mistake if anyone sees one I would appreciate a kick

Jim

_________________
Jim

I have decided that I am no longer going to plan anything in advance. In a court of law this is called Pre-Meditated, and does not look good for the defense.....

Timer function not working properly? Check CLKDIV8 Fuse first Wink
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits