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
larryvc
PostPosted: May 25, 2012 - 08:08 PM
Raving lunatic


Joined: Dec 06, 2007
Posts: 2512
Location: Redmond, WA USA

Ok.

You had this function misspelled: InitCommAdpter s/b InitCommAdapter.

Hmm, how did all of this work before?

I put in temporary fixes for the missing externs and now it builds correctly with only the 4 warnings about "dummy".

_________________
Larry

Those afraid to embrace the future will quickly fade into the past. - larryvc
 
 View user's profile Send private message  
Reply with quote Back to top
larryvc
PostPosted: May 26, 2012 - 12:35 AM
Raving lunatic


Joined: Dec 06, 2007
Posts: 2512
Location: Redmond, WA USA

I did a test betweeen the modified project with inline and one with no inlines. This test was done with optimization set to -O1.

inlines:
Code:
Done executing task "RunCompilerTask".
   Task "RunOutputFileVerifyTask"
            Program Memory Usage    :   51602 bytes   39.4 % Full
            Data Memory Usage       :   21954 bytes   33.8 % Full
            EEPROM Memory Usage    :   1919 bytes   46.9 % Full

no inlines:
Code:
Done executing task "RunCompilerTask".
   Task "RunOutputFileVerifyTask"
            Program Memory Usage    :   51672 bytes   39.4 % Full
            Data Memory Usage       :   21954 bytes   33.8 % Full
            EEPROM Memory Usage    :   1919 bytes   46.9 % Full

Wow! 70 bytes.

Optimization set to -Os gave 48600 bytes vs 48656 bytes.

If you want the cleaned up no inline version just ask.

Code:
==================================================================================

_________________
Larry

Those afraid to embrace the future will quickly fade into the past. - larryvc
 
 View user's profile Send private message  
Reply with quote Back to top
Larrydew
PostPosted: May 31, 2012 - 10:36 PM
Newbie


Joined: May 22, 2012
Posts: 17


I resolved my problems by eliminating all of the inline functions calls across modules. However when I turn off optomization (none -O0) the compiler chokes on an inline function that is declared/implimented in the same module.
Code:
/**********************************************************************************
**
**  Function inline void EEPROM_Wait( void )
**
**  Return: void
**
**  Purpose: Wait for the Write Cycle to complete
**           First wait for the write cycle to begin
**           then wait for it to complete.
**
**********************************************************************************/
inline void EEPROM_Wait( void )
{
  while ( EECR & (1<<EEPE)); // wait here until done
}

/**********************************************************************************
**
**  Function void EEPROM_Write( uint16_t addr, byte data )
**
**  Return: void
**
**  Purpose: Helper function to actually write the uint16_t data into the EEPROM
**
**********************************************************************************/
void EEPROM_Write( uint16_t addr, byte data )
{
  EEPROM_Wait();
  EEAR = addr;
  EEDR = data;
  CS_ENTER;
  EECR |= (1<<EEMPE); // write logical 1 to EEMPE
  EECR |= (1<<EEPE);  // start the eeprom write
  CS_LEAVE;
}
The error is
Code:
undefined reference to " EEPROM_Write"

Any new Ideas?
 
 View user's profile Send private message  
Reply with quote Back to top
larryvc
PostPosted: May 31, 2012 - 11:59 PM
Raving lunatic


Joined: Dec 06, 2007
Posts: 2512
Location: Redmond, WA USA

I don't know why you are receiving that error. Does seem odd though. If you would like me to take another look at the code attach it. Smile

Did you see my last post? Get rid of all the inlines in your program and you won't have any errors. The compiler is inlining for you in almost all of the cases that have optimization enabled. Give it a try and you will be able to move forward with your work. Very Happy

_________________
Larry

Those afraid to embrace the future will quickly fade into the past. - larryvc
 
 View user's profile Send private message  
Reply with quote Back to top
EW
PostPosted: Jun 01, 2012 - 05:31 AM
Raving lunatic


Joined: Mar 01, 2001
Posts: 4960
Location: Rocky Mountains

And IIRC, avr-libc already has EEPROM functions. So why is the wheel being reinvented?...

_________________
Eric Weddington
Marketing Manager
Open Source & Community
Atmel
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
larryvc
PostPosted: Jun 01, 2012 - 06:49 AM
Raving lunatic


Joined: Dec 06, 2007
Posts: 2512
Location: Redmond, WA USA

Larrydew wrote:
The error is
Code:
undefined reference to " EEPROM_Write"


Are you sure that is the error message you received? EEPROM_Write is not defined as inline.

_________________
Larry

Those afraid to embrace the future will quickly fade into the past. - larryvc
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jun 01, 2012 - 09:35 AM
10k+ Postman


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

"undefined reference" is a link error meaning "I took all the .o files that were presented, at least one calls a function called EEPROM_Write() but amongst all the .o files I cannot find one that actually provides this function". This is usually because the .c file that provides EEPROM_Write() is not listed in the list of files to compile.

Like Eric I wonder why you are writing EEPROM functions when the (tried and tested) functions in AVR-LIbC are available:

http://www.nongnu.org/avr-libc/user-man ... eprom.html

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
Larrydew
PostPosted: Jun 01, 2012 - 02:46 PM
Newbie


Joined: May 22, 2012
Posts: 17


I apologize for a miss type in the error message, it should be EEPROM_Wait not EEPROM_Write, however you all seem to be missing the point. Yes, I read your earlier post and I did remove the inline directive from all files (making them standard functions) where the functions were called from outside modules, This cleared the errors as long as -O0 was not used. I know that the eeprom functions exists and I have a reason to write some of my own. That said I assure you that my eeprom.c file is in the compile list. I know this because I stated that when the project optimization is set above -O0 every thing compiles and links and runs, however when only the optimization is set to -O0 do I get the errors. The code snippet I included with my last post was copied directly from the file. The declaration and implementation of EEPROM_Wait() is before the call to the function and therefore the compiler/should either directly include the code inline or create a non-inline function in the object file and link it in as such. The research I have done indicates that the compiler should try to optimize the "inline" code regardless of the optimization level (since the directive inline means optimize this code block) or simple ignore the inline directive quietly without in-lining. This version of the compiler does not seem to be following the GNU C compiler specification. All of this code compiled and ran under the AVR4 IDE and generated inline code regardless of the -Ox setting.

Again I apologize for the typo with the error message and the confusion it caused.
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jun 01, 2012 - 02:55 PM
10k+ Postman


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

Quote:

This version of the compiler does not seem to be following the GNU C compiler specification.

In what sense. By the way if you want optimization but don't want the compiler to inline small functions then us -fno-inline-small-functions to persuaded it not to.

As I still haven't got the first idea what you are really complaining about here I wonder if you could put together a set of (minimal!) project files that exhibit the issue you are seeing?

_________________
 
 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