undefined reference to "Timer0_RegisterCallbackFunction

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

hi, i'm newbie here and avr.., i've some problem when i try to compile my source code..
:cry: .., 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..

Attachment(s): 

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

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.

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

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 http://www.orelectronics.net

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

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.

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

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

JW

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

It appears to be here:

http://gandalf.arubi.uni-kl.de/a...

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

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

ok i'm trying it, thanks all :D

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

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

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

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.

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

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

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

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.

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

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

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

OK now change:

#include 
#include 
#include 
#include 
#include 

to be:

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

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

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

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

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?

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'll check again my source code...

thanks

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

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: https://www.avrfreaks.net/index.p... and get that working first. Then figure out how to use the ADC as a later issue.

Smiley

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

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.. :shock:
[/sarkasm]

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 don't really understand about link a program :D

Quote:
I'd strongly recommend that you read Dean's Butterfly LCD Tutorial: https://www.avrfreaks.net/index.p... ... 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

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

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.

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

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 http://www.orelectronics.net

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

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.

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

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

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

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

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

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

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)

https://www.avrfreaks.net/index.p...

And the excellent tutorial on interrupts:

https://www.avrfreaks.net/index.p...

And the one on bit manipulation:

https://www.avrfreaks.net/index.p...

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 http://www.orelectronics.net

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

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.. :D,

best regards

MA

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

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 http://www.orelectronics.net

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

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

Attachment(s): 

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

Sounds like another customer for the Arduino.

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

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

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

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

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

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

Smiley