Coding Error (MPLAB XC8)

Thread Starter

enciklinux

Joined Dec 8, 2021
13
This is my full code
https://pastebin.com/kbJ5qgQ0

I got 2 error.

1)

1641882171705.png
main.c:112:6: error: expected identifier or '('
{
^

2)

1641882255510.png
main.c:61:32: warning: implicit conversion loses floating-point precision: 'double' to 'float' [-Wconversion]
ActualTemp = (ADCResult*5.0)/10.24; //conver data into temperature (LM35 produces 10mV per degree celcius)
~ ~~~~~~~~~~~~~~~^~~~~~
main.c:62:13: warning: passing 'unsigned char [10]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
sprintf (stringKeyActual, "%.2g", ActualTemp ); //comnvert voltage to string
^~~~~~~~~~~~~~~

Stuck with this error for whole day, decide to seek help over here. Thank you very much.
 

bug13

Joined Feb 13, 2012
2,002
Have a read on C syntax

Should be this:
void lcd_setCursor (unsigned char col, unsigned char row)
{
    lcd_cmd(row*0x40+col+0x80);
    delay (1);
}
 

Thread Starter

enciklinux

Joined Dec 8, 2021
13
change this:
C:
double ActualTemp = 0;
char stringKeyActual[10] = { 0 };
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'D:/BEU/2. BEU30063 MICROPROCESSOR AND MICROCONTROLLER/LAB SHEET/Mini Project/Proteus project/LCD SIGN BOARD/MPLAB Source File/test/kote.X'
make -f nbproject/Makefile-default.mk dist/default/production/kote.X.production.hex
make[2]: Entering directory 'D:/BEU/2. BEU30063 MICROPROCESSOR AND MICROCONTROLLER/LAB SHEET/Mini Project/Proteus project/LCD SIGN BOARD/MPLAB Source File/test/kote.X'
"C:\Program Files\Microchip\xc8\v2.32\bin\xc8-cc.exe" -mcpu=18F4550 -c -mdfp="C:/Program Files/Microchip/MPLABX/v5.50/packs/Microchip/PIC18Fxxxx_DFP/1.2.26/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx32 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/main.p1 main.c
"C:\Program Files\Microchip\xc8\v2.32\bin\xc8-cc.exe" -mcpu=18F4550 -Wl,-Map=dist/default/production/kote.X.production.map -DXPRJ_default=default -Wl,--defsym=__MPLAB_BUILD=1 -mdfp="C:/Program Files/Microchip/MPLABX/v5.50/packs/Microchip/PIC18Fxxxx_DFP/1.2.26/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -mwarn=-3 -Wa,-a -msummary=-psect,-class,+mem,-hex,-file -ginhx32 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -Wl,--memorysummary,dist/default/production/memoryfile.xml -o dist/default/production/kote.X.production.elf build/default/production/main.p1
:20273:: warning: (1311) missing configuration setting for config word 0x300000; using default
:20273:: warning: (1311) missing configuration setting for config word 0x300001; using default
:20273:: warning: (1311) missing configuration setting for config word 0x300002; using default
:20273:: warning: (1311) missing configuration setting for config word 0x300003; using default
:20273:: warning: (1311) missing configuration setting for config word 0x300005; using default
:20273:: warning: (1311) missing configuration setting for config word 0x300006; using default
:20273:: warning: (1311) missing configuration setting for config word 0x300008; using default
:20273:: warning: (1311) missing configuration setting for config word 0x300009; using default
:20273:: warning: (1311) missing configuration setting for config word 0x30000A; using default
:20273:: warning: (1311) missing configuration setting for config word 0x30000B; using default
:20273:: warning: (1311) missing configuration setting for config word 0x30000C; using default
:20273:: warning: (1311) missing configuration setting for config word 0x30000D; using default
:0:: error: (499) undefined symbol:
_init_ADC(dist/default/production\kote.X.production.o)
(908) exit status = 1
nbproject/Makefile-default.mk:138: recipe for target 'dist/default/production/kote.X.production.hex' failed
make[2]: Leaving directory 'D:/BEU/2. BEU30063 MICROPROCESSOR AND MICROCONTROLLER/LAB SHEET/Mini Project/Proteus project/LCD SIGN BOARD/MPLAB Source File/test/kote.X'
nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failed
make[1]: Leaving directory 'D:/BEU/2. BEU30063 MICROPROCESSOR AND MICROCONTROLLER/LAB SHEET/Mini Project/Proteus project/LCD SIGN BOARD/MPLAB Source File/test/kote.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [dist/default/production/kote.X.production.hex] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 5s)
now this the error after i tried to build the code
 

Ian Rogers

Joined Dec 12, 2012
988
The second part was only a warning....

char stringKeyActual[10] = { 0 };

This won't work you should stay with how it was..
char stringKeyActual[10]; or initialise all 10...

Conversion from double to float in this instance isn't so dire anyway...
I normally use an external Ftoa() then pass a string rather than sprintf() doing it..

Should work as expected just removing the extra ";" at the end of the function...
 

ApacheKid

Joined Jan 12, 2015
616
now this the error after i tried to build the code
That error seems to be a linking error, not a C language error. It seems that the system expects to find a function named _initADC.

The linker is unable to find that and so cannot create the final, complete program/executable.
 
Top