Making hexfile w constants to load via AVRStudio. How???

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi!
I have been trying to make a hex-file with ONLY constants in assembler to load into the EEPROM part of my ATmega128. I only get :00000001FF whn assembling:

;Addresses in EEPROM
.eseg
.ORG 0
LASTFREQUENCYADDRESS:	.DW  0x1930, 0x39
.ORG 0x100
DEFFREQUENCYFACTOR1Hz:	 .DW  11, 	0
DEFFREQUENCYFACTOR10Hz: .DW  107,  0

What is missing/wrong!
As you have read this: thanks for tryng!
Nils

Nils in Uppsala, Sweden
SM5DEH since 50 years!
nils at meditalk dot com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I added a bit of code in the cseg because the assembler didn't work too well without it and this is the result.

.cseg
test:
000000 0000 nop

;Addresses in EEPROM
.eseg
.ORG 0
000000 LASTFREQUENCYADDRESS: .DW 0x1930, 0x39
000000 30 19
000002 39 00
.ORG 0x100
000100 DEFFREQUENCYFACTOR1Hz: .DW 11, 0
000100 0b 00
000102 00 00
000104 DEFFREQUENCYFACTOR10Hz: .DW 107, 0
000104 6b 00
000106 00 00

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tried with a cp r12,r11; will try your way!

Nils in Uppsala, Sweden
SM5DEH since 50 years!
nils at meditalk dot com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Make sure you put the .cseg bit, The assembler was deleting the output files after assembling without it. You can of course put the eseg part at the end of your main code and it will be assembled at the same time as your main code.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for trying, John, but I still get a result w/o .eseg! Althou I get a cseg section now, thanks to you! I am normally using WinAVR (beautiful sw!) writing c-code: can I add EEPROM content using C in .c-file??? Do you know?
And thanks again, from snowy Uppsala
Nils

Nils in Uppsala, Sweden
SM5DEH since 50 years!
nils at meditalk dot com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The cseg part puts code in your projectname.hex file, the eseg part puts code in your projectname.eep file. The .hex file gets programmed into the flash, the eep file gets programmed into the EEPROM. If you use a programmer like AVRprog you see the 2 parts of the programming sequence. Also remember that you need to make up a project to use avrstudio and the assembler. I know little about C. have tried it for about 20 years but quicly revert to assembler. May want to put the question in the AVRgcc forum.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello!

This is how I'm doing it in WinAVR :

uint8_t eeprom_seconds __attribute__ ((section (".eeprom")))=99;

I'm not sure if there's a way to define what address the variables will be located at but you access them like this :

int8_t ee_seconds;

ee_seconds=eeprom_read_byte(&eeprom_seconds);

The address seems to be resolved at compile-time.

Osku

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

...study the subject of assigning addresses given at program writing time... IFF I find out I will tip you!
Greetings to the front side of Sweden by the way!
Nils in Uppsala

Nils in Uppsala, Sweden
SM5DEH since 50 years!
nils at meditalk dot com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello again!

I found this thread about placing the variables at specified addresses

[url]
https://www.avrfreaks.net/index.p...
[/url]

It's about variables in FLASH, but shouldn't be too hard to change it to EEPROM.

Hälsningar Osku

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Perhaps I didn't understand the question correctly. The example I show above works and you get 2 data files as a result, one is the hex file for the flash which you don't need and the other is the .eep file which you want. Can you please confirm that your assembler generates these 2 files? Also if you are using studio for debugging you MUST upload/download the memory file to your chip before you can see your data in the eeprom section of your memory.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly