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
hakagiri
PostPosted: Jul 05, 2011 - 04:55 PM
Newbie


Joined: Jul 01, 2011
Posts: 14


hi, i'm newbie here and avr.., i've some problem when i try to compile my source code..
Crying or Very sad .., there are like
Quote:

undefined reference to"Timer0_RegisterCallbackFunction",
undefined reference to"LCD_UpdateRequired", etc..

I attach the source code, i take this from bf_gcc with some editing cause i just need light meter code

thanks..
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jul 05, 2011 - 05:01 PM
10k+ Postman


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

When you see "undefined reference" it's an error from the linker that says "all the .c and .S files in the project have been built to create .o files, I've then joined them all together but in there there are some calls to XXXXXXX which none of the .c or .S files provided".

In other words you forgot to add the .c files that provide Timer0_RegisterCallbackFunction() and LCD_UpdateRequired() to the list of .c files to be compiled.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
ka7ehk
PostPosted: Jul 05, 2011 - 05:26 PM
10k+ Postman


Joined: Nov 22, 2002
Posts: 12053
Location: Tangent, OR, USA

To expand a bit on Clawson's post, if you are using AVR studio, you need to add those .c files to the list of project files. In Studio4, that is done in the list of project files and there may be a way from the File menu to do that, also (Studio is not on the machine I am using right now). I don't remember the precise mechanism but it may use a right mouse-click on the project name, or something like that. In Studio5, I have no clue, but its probably something similar.

Cheers,
Jim

_________________
Jim Wagner
Oregon Research Electronics, Consulting Div.
Tangent, OR, USA

"The only thing standing between us and victory is defeat" P.G.Wodhouse in Wooster & Jeeves series
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jul 05, 2011 - 05:39 PM
10k+ Postman


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

Quote:

I don't remember the precise mechanism but it may use a right mouse-click on the project name, or something like that.

Indeed it is then use "Add Existing Source File(s)..." and pick them in the resultant file selector. Life is simpler if they happen to be in the same directory as the other project files.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
wek
PostPosted: Jul 05, 2011 - 05:40 PM
Raving lunatic


Joined: Dec 16, 2005
Posts: 3089
Location: Bratislava, Slovakia

hakagiri wrote:
I attach the source code, i take this from bf_gcc
What is bf-gcc?

JW
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
clawson
PostPosted: Jul 05, 2011 - 05:42 PM
10k+ Postman


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

It appears to be here:

http://gandalf.arubi.uni-kl.de/avr_proj ... tml#bf_gcc

I take it that means the GCC conversion of the Atmel Butterfly code that Martin Thomas did.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
hakagiri
PostPosted: Jul 05, 2011 - 06:02 PM
Newbie


Joined: Jul 01, 2011
Posts: 14


ok i'm trying it, thanks all Very Happy
 
 View user's profile Send private message  
Reply with quote Back to top
hakagiri
PostPosted: Jul 05, 2011 - 06:23 PM
Newbie


Joined: Jul 01, 2011
Posts: 14


i've tried this option and get some error like no such file/directory but i've copied all .c and .h in one folder, so any solution for this??

thanks
 
 View user's profile Send private message  
Reply with quote Back to top
Koshchi
PostPosted: Jul 05, 2011 - 06:26 PM
10k+ Postman


Joined: Nov 17, 2004
Posts: 13848
Location: Vancouver, BC

Quote:
but i've copied all .c and .h in one folder
But did you add those .c files to the project?

_________________
Regards,
Steve A.

The Board helps those that help themselves.
 
 View user's profile Send private message  
Reply with quote Back to top
hakagiri
PostPosted: Jul 05, 2011 - 06:43 PM
Newbie


Joined: Jul 01, 2011
Posts: 14


Quote:
Quote:
but i've copied all .c and .h in one folder
But did you add those .c files to the project?


sure, i've.. that's make me confuse *_*'

MA
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jul 05, 2011 - 06:44 PM
10k+ Postman


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

Quote:

and get some error like no such file/directory

"some error" - very descriptive. Any chance of saying what "some error" actually is and I mean the EXACT wording.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
hakagiri
PostPosted: Jul 05, 2011 - 06:47 PM
Newbie


Joined: Jul 01, 2011
Posts: 14


Quote:

../uvmeter.c:11:25: error: pgmspacehlp.h: No such file or directory
../uvmeter.c:15:18: error: main.h: No such file or directory
../uvmeter.c:16:17: error: ADC.h: No such file or directory
../uvmeter.c:17:17: error: BCD.h: No such file or directory
../uvmeter.c:18:27: error: LCD_functions.h: No such file or directory
../uvmeter.c:19:20: error: timer0.h: No such file or directory


that's error i get.. i've tried to move in same folder..
 
 View user's profile Send private message  
Reply with quote Back to top
clawson
PostPosted: Jul 05, 2011 - 07:08 PM
10k+ Postman


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

OK now change:
Code:
#include <main.h>
#include <ADC.h>
#include <BCD.h>
#include <LCD_functions.h>
#include <timer0.h>

to be:
Code:
#include "main.h"
#include "ADC.h"
#include "BCD.h"
#include "LCD_functions.h"
#include "timer0.h"

and make sure the names on disk are exactly that case.

_________________
 
 View user's profile Send private message  
Reply with quote Back to top
hakagiri
PostPosted: Jul 06, 2011 - 02:35 AM
Newbie


Joined: Jul 01, 2011
Posts: 14


that's fix the problem, but another error come... like
Quote:

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr5/crtm169.oSad.init9+0x0): undefined reference to `main'
button.o: In function `PinChangeInterrupt':
D:\BACKUP KULIAH\bahan TA\Program\uvmeter1\default/../button.c:162: undefined reference to `gPowerSaveTimer'
LCD_driver.o: In function `__vector_22':
D:\BACKUP KULIAH\bahan TA\Program\uvmeter1\default/../LCD_driver.c:299: undefined reference to `gAutoPressJoystick'
D:\BACKUP KULIAH\bahan TA\Program\uvmeter1\default/../LCD_driver.c:305: undefined reference to `gAutoPressJoystick'


thanks

best regards,
MA
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: Jul 06, 2011 - 09:11 AM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18581
Location: Lund, Sweden

Quote:

undefined reference to `main'

There is a generic explanation above on how to interpret 'undefined reference to something". Did you read it? Did you understand it?

In essence, when building the application a definition of the main function can not be found.

Have you supplied such a definition?
Have you added the file with that definition to the project?

Absolute base-line: Do you know that this function is needed in any and all C programs, and do you understand it's function?
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
hakagiri
PostPosted: Jul 06, 2011 - 01:37 PM
Newbie


Joined: Jul 01, 2011
Posts: 14


i'll check again my source code...

thanks
 
 View user's profile Send private message  
Reply with quote Back to top
smileymicros
PostPosted: Jul 06, 2011 - 03:41 PM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

It seems to me that you've chopped up the original code provided by Martin Thomas without really understanding the basic principles for using AVRStudio to compile and link a program.

The Butterfly code has some very complex cross connections in the various modules. The relationship between the LCD and other modules is particularly fraught.

I'd strongly recommend that you read Dean's Butterfly LCD Tutorial: http://www.avrfreaks.net/index.php?name ... mp;t=36234 and get that working first. Then figure out how to use the ADC as a later issue.

Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
JohanEkdahl
PostPosted: Jul 06, 2011 - 03:44 PM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18581
Location: Lund, Sweden

Quote:
Then figure out how to use the ADC as a later issue.

[sarkasm]
Are you saying that there often is no such thing as immediate reward w/o any lengthy learning process involved?!?

I'm shocked and flabbergasted.. Shocked
[/sarkasm]
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
hakagiri
PostPosted: Jul 06, 2011 - 04:35 PM
Newbie


Joined: Jul 01, 2011
Posts: 14


i don't really understand about link a program Very Happy

Quote:
I'd strongly recommend that you read Dean's Butterfly LCD Tutorial: http://www.avrfreaks.net/index.php?name ... mp;t=36234

i'll try it..

oh ya, i've try pc_comm from smileymicro tutorial, after download the code to butterfly, there's nothing apears on the hyper terminal...?? can u help?

best regards
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: Jul 06, 2011 - 05:55 PM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18581
Location: Lund, Sweden

Quote:
can u help?

Can: Maybe. Want to? No.

1. You are jumping from thing to thing here. You've now opened up the subject of smileymicros tutorial w/o the original question/problem being resolved. At our end this looks like you're abandoning the original problem, and we've spent time helping you in vain. Even if you've not abandoned the original problem, this discussion is now a "moving target". We loathe moving targets.

2. You are not supplying answers to questions asked. I was trying to determine your level of knowledge on the C language by asking about the main() function. You've not bothered to answer. So now we (still) don't know at what level we should supply help - obviously risking that help we give is not the one needed and out time wasted once again.

3. The formulation "there's nothing apears on the hyper terminal...?? can u help?" clearly indicates that you either can to do basic fault seeking, or could but haven't, or have but won't tell us. So once again, we need to start at some point, but you don't give us a chance determining where that is. Again any advice we give has a high likelyhood to be wasted.

No. I won't help.

Think about this: The quality of the answers you get is correlated with the quality of the question you ask. (Ask bad questions and people will walk away. Ask ood questions (and make good answers to counter/followup-quations!) and people will stay and help you.)

Me? I'm out of here.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
ka7ehk
PostPosted: Jul 06, 2011 - 08:57 PM
10k+ Postman


Joined: Nov 22, 2002
Posts: 12053
Location: Tangent, OR, USA

Crystal ball is VERY fuzzy but I wonder if the hakagirl's "real" quest is: "I just wanna get SOMETHING running. I don't know diddly about C, and not thrilled about spending all that time, so I just grab something off the internet to RUN!"

This is NOT intended to put (presumed) her down, in the least. We have had a spate of such queries in the last few months. Perhaps they represent the "new paradigm" of what it means to "program". We can try to guide. We can encourage. We can point to resources. We can nudge and suggest. OR, we can complain. We can throw up our hands and walk away (and I begrudge no body who does, because it is really, really, frustrating). We can tell everyone about all the effort we went through when WE learned "it".

So, lets try to be a bit understanding. Any of you who have techno-teens in your family or among close friends know what we are up against. They want to do without learning, but, if they stick with it, they will end up learning whether they intend to or not. At least part of what they learn (in the microcontroller programming realm, at least) will depend on their interactions with us.

In THIS particular case, I think we really need to ask: what is the OP's goal? What are YOU trying to do. And, how can we help you do do that? My very cloudy crystal ball suggests that you don't care what it is that you get running. but you want something, anything, that you can SEE do something.

For hakagirl, you need to know a few "facts". First is that every c program needs a function named "main()". It is normally written so that it contains an endless loop that NEVER exits. Second is that what you probably got, previously, were "libraries". These are chunks of code that are intended to be added on to an existing program to do something. They will not run, by themselves. YOU have to supply the core program that it gets added to.

Jim

_________________
Jim Wagner
Oregon Research Electronics, Consulting Div.
Tangent, OR, USA

"The only thing standing between us and victory is defeat" P.G.Wodhouse in Wooster & Jeeves series
 
 View user's profile Send private message  
Reply with quote Back to top
JohanEkdahl
PostPosted: Jul 06, 2011 - 09:51 PM
10k+ Postman


Joined: Mar 27, 2002
Posts: 18581
Location: Lund, Sweden

Quote:

Crystal ball is VERY fuzzy but I wonder if the hakagirl's "real" quest is: "I just wanna get SOMETHING running. I don't know diddly about C, and not thrilled about spending all that time, so I just grab something off the internet to RUN!"

Then she has chosen something MUCH too complicated for a first project, Jim.
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
ka7ehk
PostPosted: Jul 06, 2011 - 10:05 PM
10k+ Postman


Joined: Nov 22, 2002
Posts: 12053
Location: Tangent, OR, USA

Oh, I agree, but has that also not been a recurring theme?

Jim

_________________
Jim Wagner
Oregon Research Electronics, Consulting Div.
Tangent, OR, USA

"The only thing standing between us and victory is defeat" P.G.Wodhouse in Wooster & Jeeves series
 
 View user's profile Send private message  
Reply with quote Back to top
hakagiri
PostPosted: Jul 07, 2011 - 01:26 AM
Newbie


Joined: Jul 01, 2011
Posts: 14


okey.. first i've learned the basic of c languange and i don't know how to program avr using c...

and I'm working on the final project for college, about uvmeter.. so i just want to know how to read uv sensor and how to displays on lcd and pc



regards

MA
 
 View user's profile Send private message  
Reply with quote Back to top
ka7ehk
PostPosted: Jul 07, 2011 - 05:31 PM
10k+ Postman


Joined: Nov 22, 2002
Posts: 12053
Location: Tangent, OR, USA

Great. You've made some progress in learning and in defining your problem.

Now, a couple of questions:

1) What is the nature of the output of the UV sensor? Is it analog or digiital?
a) If analog, what is the voltage range that you need to measure?
b) If digital, what is the interface? SPI? I2C (aka TWI)? Something else?

2) What kind of LCD do you need or want to use?

3) How do you want to communicate with the PC?

A note about program structure - typically there is a part at the beginning where you declare variables that need to be used globally (that is, anywhere in the program). Those to be accessed in an interrupt service routine also need to be declared as "volatile" in addition to their type (such as char or uint16_t).

Next, Usually, as a matter of convention, interrupt service routines (ISRs) are written out, in whole. If you need to use an ISR (common for UART, for example), be sure to look at the avrlibc documentation for the correct name for your micro. Also, note the ISR structure described, there.

Then you have a function
Code:
int main(void)
that contains the main perpetual loops of the program core. The usual first task in main() is initialization. You write to I/O ports and registers that will be used (ADC, UART, timers, and such) to give them their proper operation. After initialization, the program usually enters a big loop where status of the analog-digital converter is checked, where you trigger messages to the serial port, or write to an LCD.

Some may quibble with a few of the details that I've written, but it is, at the very least, a useful starting point. Because of the nature of what you will be doing, you may well be using libraries (especially for LCD). So, I strongly recommend reviewing the tutorial on "large" projects (anything more than a single .c file)

http://www.avrfreaks.net/index.php?name ... mp;t=48535

And the excellent tutorial on interrupts:

http://www.avrfreaks.net/index.php?name ... mp;t=89843

And the one on bit manipulation:

http://www.avrfreaks.net/index.php?name ... mp;t=37871

Be sure to scan the "Tutorials" forum. A lot of great help is there, for you.

Jim

_________________
Jim Wagner
Oregon Research Electronics, Consulting Div.
Tangent, OR, USA

"The only thing standing between us and victory is defeat" P.G.Wodhouse in Wooster & Jeeves series
 
 View user's profile Send private message  
Reply with quote Back to top
hakagiri
PostPosted: Jul 08, 2011 - 10:50 AM
Newbie


Joined: Jul 01, 2011
Posts: 14


1. the output of uvsensor is analog with voltage range between 0-3V
2. i use lcd in butterfly stk502
3. to communicate i'm using ISP,

thanks for links.. Very Happy,

best regards

MA
 
 View user's profile Send private message  
Reply with quote Back to top
ka7ehk
PostPosted: Jul 08, 2011 - 05:25 PM
10k+ Postman


Joined: Nov 22, 2002
Posts: 12053
Location: Tangent, OR, USA

Hello, MA -

Please note that ISP is used only to program a device. You cannot send data to your PC this way. Your previous post sounds as though you want to display data (from the AVR) on your PC, and ISP will not do that.

The standard methods are asynchronous serial with a UART (RS232) or USB. If you use USB with most AVRs, you will need to add a USB interface chip, such as FTDI FT232R. A few AVRs have USB built in. If you use RS232, you will need an RS232 interface chip, similar to MAX232 (there are several).

It sounds like you are using a Butterfly. IF so, you need no LCD libraries. There are tutorials about using the Butterfly LCD. Check http://www.SmileyMicros.com

You will need to use the analog-digital converter (ADC). 0-3V is an easy range to work with. There are tutorials, here, about use of the ADC.

Jim

_________________
Jim Wagner
Oregon Research Electronics, Consulting Div.
Tangent, OR, USA

"The only thing standing between us and victory is defeat" P.G.Wodhouse in Wooster & Jeeves series
 
 View user's profile Send private message  
Reply with quote Back to top
hakagiri
PostPosted: Jul 09, 2011 - 02:40 AM
Newbie


Joined: Jul 01, 2011
Posts: 14


hi Jim,

first thanks for ur advice, i've made little program that i attach here.., so i've problem with LCD_UpdateRequired function, cause i use Dean's lcd_driver where there's on such function..,i use this function to tell LCD that's new data came,cause when i trying the code that's no change.. do you have solution for this problem?

thanks

MA
 
 View user's profile Send private message  
Reply with quote Back to top
Kartman
PostPosted: Jul 09, 2011 - 03:19 AM
Raving lunatic


Joined: Dec 30, 2004
Posts: 8788
Location: Melbourne,Australia

Sounds like another customer for the Arduino.
 
 View user's profile Send private message  
Reply with quote Back to top
smileymicros
PostPosted: Jul 09, 2011 - 04:50 AM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

Were you able to get anything working from Dean's Tutorial? Why are you concerned about the LCD_UpdateRequired function when as you say it isn't even in Dean's Tutorial. If you can get Dean's code working what do you need that function for?

Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
hakagiri
PostPosted: Jul 09, 2011 - 05:34 PM
Newbie


Joined: Jul 01, 2011
Posts: 14


Quote:
Were you able to get anything working from Dean's Tutorial?

not all ,i need function to tell lcd that's new data came.. or u have link for lcd function?

regards

MA
 
 View user's profile Send private message  
Reply with quote Back to top
smileymicros
PostPosted: Jul 09, 2011 - 07:53 PM
Raving lunatic


Joined: Nov 17, 2004
Posts: 6137
Location: Great Smokey Mountains.

Dean's Tutorial tells you how to write to the LCD. Maybe I'm not understanding what you are asking.

Smiley

_________________
FREE TUTORIAL: 'Quick Start Guide for Using the WinAVR C Compiler with ATMEL's AVR Butterfly' AVAILABLE AT: http://www.smileymicros.com
 
 View user's profile Send private message Visit poster's website 
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