| Author |
Message |
|
|
Posted: Jul 05, 2011 - 04:55 PM |
|


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..
.., 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.. |
|
|
| |
|
|
|
|
|
Posted: Jul 05, 2011 - 05:01 PM |
|


Joined: Jul 18, 2005
Posts: 62280
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. |
_________________
|
| |
|
|
|
|
|
Posted: Jul 05, 2011 - 05:26 PM |
|


Joined: Nov 22, 2002
Posts: 12041
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
|
| |
|
|
|
|
|
Posted: Jul 05, 2011 - 05:39 PM |
|


Joined: Jul 18, 2005
Posts: 62280
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. |
_________________
|
| |
|
|
|
|
|
Posted: Jul 05, 2011 - 05:40 PM |
|

Joined: Dec 16, 2005
Posts: 3086
Location: Bratislava, Slovakia
|
|
|
hakagiri wrote:
I attach the source code, i take this from bf_gcc
What is bf-gcc?
JW |
|
|
| |
|
|
|
|
|
Posted: Jul 05, 2011 - 05:42 PM |
|


Joined: Jul 18, 2005
Posts: 62280
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
|
|
|
|
|
Posted: Jul 05, 2011 - 06:02 PM |
|


Joined: Jul 01, 2011
Posts: 14
|
|
ok i'm trying it, thanks all  |
|
|
| |
|
|
|
|
|
Posted: Jul 05, 2011 - 06:23 PM |
|


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 |
|
|
| |
|
|
|
|
|
Posted: Jul 05, 2011 - 06:26 PM |
|

Joined: Nov 17, 2004
Posts: 13828
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.
|
| |
|
|
|
|
|
Posted: Jul 05, 2011 - 06:43 PM |
|


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 |
|
|
| |
|
|
|
|
|
Posted: Jul 05, 2011 - 06:44 PM |
|


Joined: Jul 18, 2005
Posts: 62280
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. |
_________________
|
| |
|
|
|
|
|
Posted: Jul 05, 2011 - 06:47 PM |
|


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.. |
|
|
| |
|
|
|
|
|
Posted: Jul 05, 2011 - 07:08 PM |
|


Joined: Jul 18, 2005
Posts: 62280
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. |
_________________
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 02:35 AM |
|


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.o  .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 |
|
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 09:11 AM |
|


Joined: Mar 27, 2002
Posts: 18545
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? |
|
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 01:37 PM |
|


Joined: Jul 01, 2011
Posts: 14
|
|
i'll check again my source code...
thanks |
|
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 03:41 PM |
|


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
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 03:44 PM |
|


Joined: Mar 27, 2002
Posts: 18545
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..
[/sarkasm] |
|
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 04:35 PM |
|


Joined: Jul 01, 2011
Posts: 14
|
|
i don't really understand about link a program
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 |
|
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 05:55 PM |
|


Joined: Mar 27, 2002
Posts: 18545
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. |
|
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 08:57 PM |
|


Joined: Nov 22, 2002
Posts: 12041
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
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 09:51 PM |
|


Joined: Mar 27, 2002
Posts: 18545
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. |
|
|
| |
|
|
|
|
|
Posted: Jul 06, 2011 - 10:05 PM |
|


Joined: Nov 22, 2002
Posts: 12041
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
|
| |
|
|
|
|
|
Posted: Jul 07, 2011 - 01:26 AM |
|


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 |
|
|
| |
|
|
|
|
|
Posted: Jul 07, 2011 - 05:31 PM |
|


Joined: Nov 22, 2002
Posts: 12041
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
|
| |
|
|
|
|
|
Posted: Jul 08, 2011 - 10:50 AM |
|


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.. ,
best regards
MA |
|
|
| |
|
|
|
|
|
Posted: Jul 08, 2011 - 05:25 PM |
|


Joined: Nov 22, 2002
Posts: 12041
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
|
| |
|
|
|
|
|
Posted: Jul 09, 2011 - 02:40 AM |
|


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 |
|
|
| |
|
|
|
|
|
Posted: Jul 09, 2011 - 03:19 AM |
|

Joined: Dec 30, 2004
Posts: 8763
Location: Melbourne,Australia
|
|
| Sounds like another customer for the Arduino. |
|
|
| |
|
|
|
|
|
Posted: Jul 09, 2011 - 04:50 AM |
|


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
|
| |
|
|
|
|
|
Posted: Jul 09, 2011 - 05:34 PM |
|


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 |
|
|
| |
|
|
|
|
|
Posted: Jul 09, 2011 - 07:53 PM |
|


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
|
| |
|
|
|
|
|