can't open #include file avr\eeprom.h

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

Hi all! I have to make a project immediatly for my college using ATMEGA16, i've never done this before, and I feel kind of lost. If you can help me, even if my question might seem stupid to you, I will appreciate! :)

I want to store some data in EEPROM memory (I'm using CodeVisionAVR). I've found some examples on this forum, and also in datasheet, but when I compile the program, it sais that the program can't open #include file avr\eeprom.h .

I've checked the library, and indeed there wasn't any file called eeprom.h. I haven't found any on the Internet either.

Can you please tell me how can I solve this problem?

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

The code you have found is not written for CodeVision, it is likely written for avr-gcc.

Regards,
Steve A.

The Board helps those that help themselves.

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

Quote:
I have to make a project immediatly for my college using ATMEGA16, i've never done this before

It might be more educational(and quicker at this stage), to not use any libraries & use the code straight from the AVR data sheets.
Eg.

void EEPROM_write(unsigned int uiAddress, unsigned char ucData)
{
  /* Wait for completion of previous write */
  while(EECR & (1<<EEWE));
  /* Set up address and data registers */
  EEAR = uiAddress;
  EEDR = ucData;
  /* Write logical one to EEMWE */
  EECR |= (1<<EEMWE);
  /* Start eeprom write by setting EEWE */
  EECR |= (1<<EEWE);
}

unsigned char EEPROM_read(unsigned int uiAddress)
{
  /* Wait for completion of previous write */
  while(EECR & (1<<EEWE));
  /* Set up address register */
  EEAR = uiAddress;
  /* Start eeprom read by writing EERE */
  EECR |= (1<<EERE);
  /* Return data from data register */
  return EEDR;
}

Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
Riddle me this...How did the serpent move around before the fall?

Last Edited: Sat. Sep 3, 2011 - 08:59 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

It might be more educational to not use the libraries & use the code straight from the AVR data sheets.

??? It MIGHT be more educational to use the facilities of transparent EEPROM access that are built into the required toolchain.

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

Quote:
???

It depends whether the objective is to learn something about the AVR or the toolchain?.
Educationally the KISS approach is always to be preferred.
One could argue which is the KISS approach! :)

Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
Riddle me this...How did the serpent move around before the fall?

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

Quote:

One could argue which is the KISS approach!

I hear what you are saying, but claim that you will quickly lose that argument. [One might also take a side path and discuss whether OP's "port" of found GCC code is part of the assignment?!?] You gain just as much AVR knowledge from use of transparent EEPROM access as learning about the intricacies of an arcane GCC work-around.

Pointing to AVR datasheet code examples is a dubious educational recommendation given the number of holes in them. They might not even compile on the model involved.

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

Points taken!

Quote:
Can you please tell me how can I solve this problem?

The OP has two approaches, to solve his problem!

Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
Riddle me this...How did the serpent move around before the fall?

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

Thanks for your responses, last night I tried to use the codes from datasheets, also because I have to write the project in CodeVision, not in gcc.
Is there any way to see if the program works correctly without using the microcontroller yet?
I tried to write an array in EEPROM, then read the data from EEPROM and store in another array.

After I copiled the file, it seemed strange to me that it said EEPROM usage = 0%

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

I attached the code here (don't know why I couldn't post it in the message).

Can I see the values of ret[i] somehow on PC?

Thx!

Attachment(s): 

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

Quote:

Can I see the values of ret[i] somehow on PC?

For ordinary functions you can in many circumstances. Run the program in the AVR Simulator in AVR Studio.

Functions returning with the RETI instruction are interrupt service routines, and as such can never return a value. (Think about it - where would such a return value end up?)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

I downloaded the code (which, dear readers, is not a program but a bunch of snippets) and don't (because it's not a complete program) see what you are trying to achieve but please read the forgoing posts. The whole point is that CodeVision has one of the very slickest access methods for using EEPROM of any AVR compiler. Within in reason you just do something like:

int RAM_var;
eeprom int EE_var = 37;

RAM_var = EE_var;

and RAM_var gets the '37' read from the "EE_var" location in the EEPROM - it all just magically works. No need for specially written EEPROM_Write() and EEPROM_Read() routines and most definitely no need to go messing with EEAR and EEDR etc. The compiler "hides" all that when you say "RAM_var = EE_var". (it has a built in EEPROM_read())

It's like you've bought yourself a Porsche but no one showed you how to change out of 1st gear! You miss an awful lot of fun and waste an awful lot of time.

(If you had a Porsche it's an idea to have a flick through the user manual at some stage - same goes for C compilers)

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

Thanks, I tested last night on my atmel, and it works!