• AVR Freaks

Hot!digital thermometer doesnt compile

Author
aviator3679
Starting Member
  • Total Posts : 36
  • Reward points : 0
  • Joined: 2019/08/22 13:32:23
  • Location: 0
  • Status: offline
2019/08/29 03:39:23 (permalink)
0

digital thermometer doesnt compile

Hello, I am a student in EE and I am following a youtube tutorial on how to build a digital thermometer. I have followed the code but for some reason it gives me an error message even for functions that should work.I am using pic18f2580 and mplab x ide v5.25 and xc8 v1.34, also the box "Link in the peripheral library"  in the project properties is ticked. The code im using is:
 
 
#include <stdio.h>
#include <stdlib.h>
void Initialize_ADC(void);
void Initialize_LCD(void);
void DelayFor18TCY(void);
void DelayPORXLCD(void);
void DelayXLCD(void);
unsigned int ADCResult=0;
float voltage;
unsigned char ResultString[20];
void main(void)
{
OSCCON= 0x76;

Initialize_ADC();
Initialize_LCD();

while(1)
{
ConvertADC();
while(BusyADC());
ADCResult= ReadADC();
voltage= (ADCResult*5.0)/10.24;
putrsXLCD("Temp is: ");
printf(ResultString, "%.3g", voltage );
putrsXLCD(ResultString);
putrsXLCD(223);
putrsXLCD("C");
putrsXLCD(" ");
WriteCmdXLCD(0x02);
}
}
void Initialize_ADC(void)
{
OpenADC(ADC_FOSC_2 & ADC_RIGHT_JUST & ADC_2_TAD , ADC_CHO & ADC_INT_ON & ADC_REF_VDD_VSS, ADC_1ANA);
}
void Initialize_LCD(void)
{
OpenXLCD(FOUR_BIT & LINES_5x7);
while(BusyXLCD());
WriteCmdXLCD(0x06);
WriteCmdXLCD(0x0C);
putrsXLCD("Digital");
SetDDRamAddr(0x40);
putrsXLCD("Thermometer...");
for(int x=0; x<=20; x++)__delay_ms(50); 1 second delay
WriteCmdXLCD(0x01);
}
void DelayFor18TCY(void)
{
Delay10TCYx(20);
}
void DelayPORXLCD(void)
{
Delay1KTCYx(30);
}
void DelayXLCD(void)
{
Delay1KTCYx(10);
}
 
Also,the full build log is :
 
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'C:/Users/aeros/MPLABXProjects/p1.X'
make -f nbproject/Makefile-default.mk dist/default/production/p1.X.production.hex
make[2]: Entering directory 'C:/Users/aeros/MPLABXProjects/p1.X'
"C:\Program Files (x86)\Microchip\xc8\v1.34\bin\xc8.exe" --pass1 --chip=18F2580 -Q -G --double=24 --float=24 --emi=wordwrite --opt=+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=-3 --asmlist -DXPRJ_default=default --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,+plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -obuild/default/production/p1.p1 p1.c
p1.c:23: error: (192) undefined identifier "OSCCON"
p1.c:30: warning: (361) function declared implicit int
p1.c:31: warning: (361) function declared implicit int
p1.c:32: warning: (361) function declared implicit int
p1.c:34: warning: (361) function declared implicit int
p1.c:40: warning: (361) function declared implicit int
p1.c:46: warning: (361) function declared implicit int
p1.c:46: error: (192) undefined identifier "ADC_FOSC_2"
p1.c:46: error: (192) undefined identifier "ADC_RIGHT_JUST"
p1.c:46: error: (192) undefined identifier "ADC_2_TAD"
p1.c:46: error: (192) undefined identifier "ADC_CHO"
p1.c:46: error: (192) undefined identifier "ADC_INT_ON"
p1.c:46: error: (192) undefined identifier "ADC_REF_VDD_VSS"
p1.c:46: error: (192) undefined identifier "ADC_1ANA"
p1.c:51: warning: (361) function declared implicit int
p1.c:51: error: (192) undefined identifier "FOUR_BIT"
p1.c:51: error: (192) undefined identifier "LINES_5x7"
p1.c:52: warning: (361) function declared implicit int
p1.c:56: warning: (361) function declared implicit int
p1.c:58: warning: (361) function declared implicit int
p1.c:58: error: (195) expression syntax
p1.c:64: warning: (361) function declared implicit int
p1.c:69: warning: (361) function declared implicit int
(908) exit status = 1
nbproject/Makefile-default.mk:107: recipe for target 'build/default/production/p1.p1' failed
make[2]: Leaving directory 'C:/Users/aeros/MPLABXProjects/p1.X'
nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/aeros/MPLABXProjects/p1.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [build/default/production/p1.p1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
 
THANK YOU IN ADVANCE!!!
#1

3 Replies Related Threads

    ric
    Super Member
    • Total Posts : 24633
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: digital thermometer doesnt compile 2019/08/29 04:35:35 (permalink)
    +1 (1)
    You are missing the #include for <xc.h>
    Every C file under XC8 requires that.
    You seem to be using old delay routines from C18, not the nicer alternatives that come with XC8
    ( __delay_ms() and __delay_us() )
     
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    katela
    Super Member
    • Total Posts : 1466
    • Reward points : 0
    • Joined: 2013/06/11 05:25:18
    • Location: South Africa
    • Status: online
    Re: digital thermometer doesnt compile 2019/08/29 05:49:30 (permalink)
    +1 (1)
    It would be better if you learn but using at least MCC with a newer PIC model instead of this old peripheral library because it's being phased out by Microchip. These tutorials you are following were made some few years ago.

    Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
    YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
    #3
    aviator3679
    Starting Member
    • Total Posts : 36
    • Reward points : 0
    • Joined: 2019/08/22 13:32:23
    • Location: 0
    • Status: offline
    Re: digital thermometer doesnt compile 2019/08/29 17:41:41 (permalink)
    0
    Thank you all!!! I ll do what you said and see,if anything comes along Ill post again
    #4
    Jump to:
    © 2019 APG vNext Commercial Version 4.5