.eep files using ICCAVR compiler

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

Hello freaks, Is there a example of how to create a file using the ICCAVR compiler that can be written into EEPROM on the chip. In this case using a ATMega8515.
Thanks in advance

I'll believe corporations
are people when Texas executes one.

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

something like this creates it right from the c file


//---eeprom-------
#pragma data:eeprom
unsigned char eeethadd[6]={0x00,0x11,0x22,0x00,0x00,0x00}; //eth add 
unsigned char eeipadd[4]={192,168,1,200}; //ip add
unsigned char eeport[2]={0x13,0x89}; //port 5001 
#pragma data:data

Imagecraft compiler user

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

Thanks, I will give it a try. I only want to store a version number for verification later.
===================================================
update: (bobgardner)
I used your example and it works fine. I didn't see that the compiler created a *.eep file and not clear how this works. I can say that I don't understand the pragma directives, never did. I did program the device and then created a eeprom file and did a eeprom read from the device using Stdio, the data was there.
I will now have to get better indoctrinated on using pragma directives.
Never to old to learn something new!
Happy New year.

I'll believe corporations
are people when Texas executes one.

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

@bobgardner

when i defined some varibles in the eeprom like the flowing methlod :

#pragma data:eeprom
unsigned char eeethadd[6]={0x00,0x11,0x22,0x00,0x00,0x00}; //eth add
unsigned char eeipadd[4]={192,168,1,200}; //ip add
unsigned char eeport[2]={0x13,0x89}; //port 5001

 

all the variables are located in the address from 0,if i want to locate all the variables start from 0x10,how should i define thoses variables?

I'm learning AVR mcu

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

Save 15 bytes of 0xff?

Imagecraft compiler user

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

@bodgardner
Yes,I don't want to use eeprom space(0x00-0x0f).So I hope define some variables start from 0x10 address,how should I do ?(ICCAVR compiler)

I'm learning AVR mcu

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

Simple

 

#pragma data:eeprom
unsigned char fill[16]; //skip first 16 bytes of eeprom

unsigned char yourdata[];

#pragma data:data

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

ki0bk wrote:
Simple #pragma data:eeprom unsigned char fill[16]; //skip first 16 bytes of eeprom unsigned char yourdata[]; #pragma data:data

Well, maybe not so simple, depending on your toolchain and version and optimization level and code generation conventions and the phase of the moon.

 

There is nothing in the rules of C that says that the variables need to be placed in memory in the order of definition/declaration.  Now, perhaps the toolchain in question will indeed postulate this behaviour.  [...and then it would be interesting to know how multiple compilation units are handled...]

 

If you want variables laid out in a particular order, then put them into a structure.  The C compiler cannot re-order that.

 

Now, how you place that structure at a particular address will depend on your toolchain.

 

It would be interesting to learn of the need to skip 16 bytes.

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

I tought a way to solve the issue but failed at last.
#pragma data:eeprom
Unsigned char * pointer=(unsigned char *)0x10;//define pointer
*pointer=0x12;//my data
pointer++;
*pointer=0x34;//my second data
#pragma data:data
After compile ,it fail to pass compiling.Does it so difficult to define a data to a particular addres? I'm going to crazy about this situation.

I'm learning AVR mcu

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

You can not put "code" in the eeprom, what was wrong with defining 16 bytes of fill data?

The real question is why does it mater where in the eeprom the data is located?   Your going to reference it by it's variable name anyway!

 

Jim

 

 

 

 

 

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

Yes,it's true that I don't put code in eeprom space.The reason I want to lay my data in the particular address is that I will read the particular address to get the data in my flash code.they are very important rating data.i will often compare real-time temperature with that eeprom data.

I'm learning AVR mcu

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

So, use the variable name.  The compiler will indeed "put the address in the flash code".  But you said "data in my flash code" -- I have no idea what you mean by that.  Simply put the data into flash?  But they you can't change it at run time.

 

I'm confused.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Catch you later.i'm going to sleep now.it's 11:00 pm here.

I'm learning AVR mcu

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

This old thread was about putting stuff in eeprom at compile time/ programming time. I think I remember that the vars have to be inititalized like in the example I showed. But you can certainly write to any address in eeprom. Its all in the imagecraft help file. eewritebytes(something something somethingelse). Aint manuals fun to read? Its on page 141 of the iccavr.pdf file in the help directory.

 

Imagecraft compiler user

Last Edited: Wed. Jun 1, 2016 - 01:33 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

I don't want to use eeprom space(0x00-0x0f) because I have saved another important data .So I hope define some variables start from 0x10 address(ICCAVR compiler).

Maybe i have to find the answer in the imagecraft  manuals .

 

I'm learning AVR mcu

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

Oh great a f**ing cross post! I just wasted my time giving an answer on another copy of this. Thanks for wasting my life - that is 2 minutes I'm never going to get back!

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

Thanks eveybody.I have figured it out from your help.

I'm learning AVR mcu