mityeltu 0 Posted April 18, 2010 Report Share Posted April 18, 2010 (edited) I'm stumped. I have been banging away at this project for more than 6 hours trying to get the sourceboost commands to work. They won't even compile. All I want ton do is read the ad result into a variable and then display it on an lcd. The lcd works fine. Here is the stripped down adc only code that won't copmpile. I compared it to what is done in the adc example, and everything is done the same, just not the same way... I am using the 16F887 with 8MHz internal oscillator. Can anyone please helkp me? I get this error when compiling: Error: Unresolved external function:'adc_measure(unsigned char)' I tried declaring vartious combinations of variables locally and globally, but I frankly don't understand what thjat error even means. #include <system.h> #include <adc.h> //short ad_res; //unsigned char ch; void main() { //unsigned char ch short ad_res; char one, two, three; unsigned char t = 500; osccon = 0x71; intcon = 0x00; set_bit(adcon0,0); adcon1 = 0x80; ansel = 0xe0;//channels 5,6,7 porte 0,1,2 anselh = 0x00; trisa = 0x00; porta = 0x00; trisb = 0x00; portb = 0x00; trise = 0xff; while(1) { delay_ms(t); ad_res = adc_measure( 5 ); ad_res = ad_res / 4; three = (ad_res % 10) + 48; ad_res /= 10; two = (ad_res % 10) + 48; ad_res /= 10; one = ad_res + 48; } } Edited April 18, 2010 by mityeltu Quote Link to post Share on other sites
davidb 0 Posted April 18, 2010 Report Share Posted April 18, 2010 I am guessing you haven't added the adc library file (adc.pic16.lib) to the workspace window. Regards davidb Quote Link to post Share on other sites
mityeltu 0 Posted April 19, 2010 Author Report Share Posted April 19, 2010 I am guessing you haven't added the adc library file (adc.pic16.lib) to the workspace window. Regards davidb That was it..... Thank you. Why is that not mentioned in the help file? I mean, it states that the function is declared in the .h and defined in the .lib, but there is no statement to the fact that this file has to be added to the project. Am I just supposed to know that? Thanks again.... when I get back home, I'll test it out, but at least it compiles now. Quote Link to post Share on other sites
davidb 0 Posted April 19, 2010 Report Share Posted April 19, 2010 That was it..... Thank you. Why is that not mentioned in the help file? I mean, it states that the function is declared in the .h and defined in the .lib, but there is no statement to the fact that this file has to be added to the project. Am I just supposed to know that? The reference manuals (help) are not ideal and a sentence or so on creating projects with several files and the use of libraries would be helpful to newbies. There are a few references to this on the forum and also a mention about c and lib files in the Tip Of The Day. Basically any library function used must have it's .lib file added to the project. The only exception to this is the libc file which SourceBoost IDE adds automatically when linking. If you use MPLAB instead of the SB IDE then the appropriate libc must be added to the project as well. Despite the poor references and a few compiler quirks and ommisions I think you will find the overall package effective and very good value. Good luck with the rest of your project. Regards davidb Quote Link to post Share on other sites
mityeltu 0 Posted April 20, 2010 Author Report Share Posted April 20, 2010 The reference manuals (help) are not ideal and a sentence or so on creating projects with several files and the use of libraries would be helpful to newbies. There are a few references to this on the forum and also a mention about c and lib files in the Tip Of The Day. Basically any library function used must have it's .lib file added to the project. The only exception to this is the libc file which SourceBoost IDE adds automatically when linking. If you use MPLAB instead of the SB IDE then the appropriate libc must be added to the project as well. Despite the poor references and a few compiler quirks and ommisions I think you will find the overall package effective and very good value. Good luck with the rest of your project. Regards davidb Fair enough. But I don't have to include anythig but the lcd_driver.h file for that to work. I understand from reading the file that the functions have been both declared and defined within a single file, but that sort of inconsistency is not going to make it simpler. Not complaining at you, just complaining. Thank you for the help and the insight. Sincerely, Tim Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.