PIC: 18F25K22 Unable to build projects - Page 1
Forum section: electronics / general

author: Ramazan
author_rank: Newbie
timestamp: February 01, 2021, 10:26:47 pm
content: Hi guys, I'm quite new to PIC and MPLAB coding process. I made a project with using MPLAB MCC but when i try to build the project I'm getting some errors which I don't know how to fix. Any help is appreciated. Compiler is XC8 v2.31 and PIC is 18F25K22The output of the programCLEAN SUCCESSFUL (total time: 6ms)make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-confmake: Entering directory 'D:/Dersler/Master/UNAM/Thesis_PCB/Pic_Codes/TxTrialPic18FXC8v231.X'make -f nbproject/Makefile-default.mk dist/default/production/TxTrialPic18FXC8v231.X.production.hexmake: Entering directory 'D:/Dersler/Master/UNAM/Thesis_PCB/Pic_Codes/TxTrialPic18FXC8v231.X'"D:\Program Files\Microchip\xc8\v2.31\bin\xc8-cc.exe" -mcpu=18F25K22 -c -mdfp="D:/Program Files/Microchip/MPLABX/v5.45/packs/Microchip/PIC18F-K_DFP/1.4.87/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c90" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c99" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/legacy" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/proc" -I"mcc_generated_files" -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/mcc_generated_files/device_config.p1 mcc_generated_files/device_config.c"D:\Program Files\Microchip\xc8\v2.31\bin\xc8-cc.exe" -mcpu=18F25K22 -c -mdfp="D:/Program Files/Microchip/MPLABX/v5.45/packs/Microchip/PIC18F-K_DFP/1.4.87/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c90" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c99" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/legacy" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/proc" -I"mcc_generated_files" -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/mcc_generated_files/pin_manager.p1 mcc_generated_files/pin_manager.c"D:\Program Files\Microchip\xc8\v2.31\bin\xc8-cc.exe" -mcpu=18F25K22 -c -mdfp="D:/Program Files/Microchip/MPLABX/v5.45/packs/Microchip/PIC18F-K_DFP/1.4.87/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c90" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c99" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/legacy" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/proc" -I"mcc_generated_files" -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/mcc_generated_files/epwm3.p1 mcc_generated_files/epwm3.c"D:\Program Files\Microchip\xc8\v2.31\bin\xc8-cc.exe" -mcpu=18F25K22 -c -mdfp="D:/Program Files/Microchip/MPLABX/v5.45/packs/Microchip/PIC18F-K_DFP/1.4.87/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c90" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c99" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/legacy" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/proc" -I"mcc_generated_files" -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/mcc_generated_files/epwm2.p1 mcc_generated_files/epwm2.c"D:\Program Files\Microchip\xc8\v2.31\bin\xc8-cc.exe" -mcpu=18F25K22 -c -mdfp="D:/Program Files/Microchip/MPLABX/v5.45/packs/Microchip/PIC18F-K_DFP/1.4.87/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c90" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c99" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/legacy" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/proc" -I"mcc_generated_files" -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/mcc_generated_files/mcc.p1 mcc_generated_files/mcc.c"D:\Program Files\Microchip\xc8\v2.31\bin\xc8-cc.exe" -mcpu=18F25K22 -c -mdfp="D:/Program Files/Microchip/MPLABX/v5.45/packs/Microchip/PIC18F-K_DFP/1.4.87/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c90" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c99" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/legacy" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/proc" -I"mcc_generated_files" -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/mcc_generated_files/tmr4.p1 mcc_generated_files/tmr4.c"D:\Program Files\Microchip\xc8\v2.31\bin\xc8-cc.exe" -mcpu=18F25K22 -c -mdfp="D:/Program Files/Microchip/MPLABX/v5.45/packs/Microchip/PIC18F-K_DFP/1.4.87/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c90" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c99" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/legacy" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/proc" -I"mcc_generated_files" -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -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"D:\Program Files\Microchip\xc8\v2.31\bin\xc8-cc.exe" -mcpu=18F25K22 -c -mdfp="D:/Program Files/Microchip/MPLABX/v5.45/packs/Microchip/PIC18F-K_DFP/1.4.87/xc8" -fno-short-double -fno-short-float -memi=wordwrite -O0 -fasmfile -maddrqual=ignore -xassembler-with-cpp -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c90" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/c99" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/legacy" -I"../../../../../../Program Files/Microchip/xc8/v2.31/pic/include/proc" -I"mcc_generated_files" -mwarn=-3 -Wa,-a -DXPRJ_default=default -msummary=-psect,-class,+mem,-hex,-file -ginhx032 -Wl,--data-init -mno-keep-startup -mno-download -mdefault-config-bits -std=c99 -gdwarf-3 -mstack=compiled:auto:auto:auto -o build/default/production/mcc_generated_files/tmr2.p1 mcc_generated_files/tmr2.cmcc_generated_files/epwm2.c:96:42: warning: implicit conversion loses integer precision: 'unsigned int' to 'unsigned char' [-Wconversion]CCP2CON = ((uint8_t)(CCP2CON & 0xCF) | ((dutyValue & 0x0003)<<4));~ ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~main.c:64:19: error: subscripted value is not an array, pointer, or vectorif (number[31 - i] == 1) {~~~~~~^~~~~~~1 error generated.make: *** [build/default/production/main.p1] Error 1make: *** Waiting for unfinished jobs....(908) exit status = 1nbproject/Makefile-default.mk:219: recipe for target 'build/default/production/main.p1' failedmcc_generated_files/epwm3.c:96:42: warning: implicit conversion loses integer precision: 'unsigned int' to 'unsigned char' [-Wconversion]CCP3CON = ((uint8_t)(CCP3CON & 0xCF) | ((dutyValue & 0x0003)<<4));~ ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~terminate called after throwing an instance of 'std::invalid_argument'what(): No such file or directoryerror: clang frontend command failed with exit code 3 (use -v to see invocation)(908) exit status = 1nbproject/Makefile-default.mk:187: recipe for target 'build/default/production/mcc_generated_files/mcc.p1' failedterminate called after throwing an instance of 'std::invalid_argument'what(): No such file or directoryerror: clang frontend command failed with exit code 3 (use -v to see invocation)make: *** [build/default/production/mcc_generated_files/mcc.p1] Error 1make: *** [build/default/production/mcc_generated_files/tmr2.p1] Error 1(908) exit status = 1nbproject/Makefile-default.mk:179: recipe for target 'build/default/production/mcc_generated_files/tmr2.p1' failedterminate called after throwing an instance of 'std::invalid_argument'what(): No such file or directoryerror: clang frontend command failed with exit code 3 (use -v to see invocation)make: *** [build/default/production/mcc_generated_files/tmr4.p1] Error 1(908) exit status = 1nbproject/Makefile-default.mk:195: recipe for target 'build/default/production/mcc_generated_files/tmr4.p1' failedterminate called after throwing an instance of 'std::invalid_argument'what(): No such file or directoryerror: clang frontend command failed with exit code 3 (use -v to see invocation)(908) exit status = 1nbproject/Makefile-default.mk:211: recipe for target 'build/default/production/mcc_generated_files/epwm2.p1' failedmake: *** [build/default/production/mcc_generated_files/epwm2.p1] Error 1make: *** [build/default/production/mcc_generated_files/epwm3.p1] Error 1terminate called after throwing an instance of 'std::invalid_argument'what(): No such file or directoryerror: clang frontend command failed with exit code 3 (use -v to see invocation)(908) exit status = 1nbproject/Makefile-default.mk:203: recipe for target 'build/default/production/mcc_generated_files/epwm3.p1' failedmake: *** [build/default/production/mcc_generated_files/pin_manager.p1] Error 1terminate called after throwing an instance of 'std::invalid_argument'what(): No such file or directoryerror: clang frontend command failed with exit code 3 (use -v to see invocation)(908) exit status = 1nbproject/Makefile-default.mk:171: recipe for target 'build/default/production/mcc_generated_files/pin_manager.p1' failedterminate called after throwing an instance of 'std::invalid_argument'what(): No such file or directoryerror: clang frontend command failed with exit code 3 (use -v to see invocation)(908) exit status = 1nbproject/Makefile-default.mk:163: recipe for target 'build/default/production/mcc_generated_files/device_config.p1' failedmake: Leaving directory 'D:/Dersler/Master/UNAM/Thesis_PCB/Pic_Codes/TxTrialPic18FXC8v231.X'make: *** [build/default/production/mcc_generated_files/device_config.p1] Error 1make: *** [.build-conf] Error 2make: *** [.build-impl] Error 2nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failedmake: Leaving directory 'D:/Dersler/Master/UNAM/Thesis_PCB/Pic_Codes/TxTrialPic18FXC8v231.X'nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failedBUILD FAILED (exit value 2, total time: 2s)The main file that I use:#include "mcc_generated_files/mcc.h"/*Main application*/#include <xc.h>#include <stdio.h> // for sprintf#include <stdint.h> // include stdint headervoid send_signal(uint32_t number) {int8_t i;//Send 9 ms burstTMR4_StartTimer();__delay_ms(9);//Send 4.5 ms spaceTMR4_StopTimer();__delay_us(4500);for (i = 0; i < 32; i++) {// If bit is 1 send 560us pulse and 1680us spaceif (number[31 - i] == 1) {TMR4_StartTimer();__delay_us(560);TMR4_StopTimer();__delay_us(1680);} // If bit is 0 send 560us pulse and 560us spaceelse {TMR4_StartTimer();__delay_us(560);TMR4_StopTimer();__delay_us(560);}}// Send end bitTMR4_StartTimer();__delay_us(560);TMR4_StopTimer();__delay_us(560);}void main(void) {// Initialize the deviceSYSTEM_Initialize();// If using interrupts in PIC18 High/Low Priority Mode you need to enable the Global High and Low Interrupts// If using interrupts in PIC Mid-Range Compatibility Mode you need to enable the Global and Peripheral Interrupts// Use the following macros to:// Enable the Global Interrupts//INTERRUPT_GlobalInterruptEnable();// Disable the Global Interrupts//INTERRUPT_GlobalInterruptDisable();// Enable the Peripheral Interrupts//INTERRUPT_PeripheralInterruptEnable();// Disable the Peripheral Interrupts//INTERRUPT_PeripheralInterruptDisable();while (1) {while (!PORTAbits.RA0) {send_signal(0x40BF00FF);__delay_ms(500);}while (!PORTAbits.RA1) {send_signal(0x40BF807F);__delay_ms(500);}while (!PORTAbits.RA2) {send_signal(0x40BF40BF);__delay_ms(500);}while (!PORTAbits.RA3) {send_signal(0x40BF20DF);__delay_ms(500);}while (!PORTAbits.RA4) {send_signal(0x40BFA05F);__delay_ms(500);}}}

author: FireBird
author_rank: Regular Contributor
timestamp: February 01, 2021, 10:34:36 pm
content: The error that I can see is that the parameter "number" is declared as a 32-bit integerCode:void send_signal(uint32_t number)but you’re trying to access it like an array.Code:if (number[31 - i] == 1)If you want to check if one of the bits is set, tryCode:if ((number >> (31 - i)) & 1)