2017-07-04 5 views
2

J'essaie d'utiliser un globalVar.h pour obtenir mon main.c nettoyé et rangé. Mais j'ai beaucoup d'erreurs que moi et mes collègues ne pouvons pas comprendre ou résoudre.Erreur:: 0: erreur: (499) symbole non défini:

Certains voudraient-ils être si gentils et me donner un indice de ce que j'aurais pu faire de mal? J'utilise MPLAB X IDE 3.60 et MPLAB XC8 pour mon PIC12F1572.

// main.c 

#include "mcc_generated_files/mcc.h" 
#include "globalVar.h" 

void SDiagnose(sd_state_t SD_STATE); 

void main(void) 
{ 
    // Initialize the device 
    SYSTEM_Initialize(); 

    INTERRUPT_GlobalInterruptEnable(); 
    INTERRUPT_PeripheralInterruptEnable(); 

    while (1) 
    { 
     if (gFlag_SDAktiv)   // Selbstdiagnose wird alle 180 Sekunden aktiviert 
     { 
      switch(gCnt_SD) 
      { 
      case 180: 
       SD_STATE = START; 
       SDiagnose(SD_STATE);      //SD-PIN auf LOW ziehen, Laden starten 
       break; 

      case 190: 
       SD_STATE = STARTMESSEN; 
       SDiagnose(SD_STATE);    //Messung des Wertes während des Ladens und der Rekuperation starten 
       break; 

      default: 
       break; 

      } 
     } 
    } 
} 

void SDiagnose(sd_state_t SD_STATE) 
{ 
    switch(SD_STATE) 
    { 
     case START: 
      PIN_SDIAGNOSE_SetDigitalOutput(); 
      PIN_SDIAGNOSE_SetLow(); 
      break; 

     case STARTMESSEN: 
      ADC1_StartConversion(); 
      break; 

     default: 
      break;  
    } 
} 

//globalVar.h 

#include <xc.h> // include processor files - each processor file is guarded. 


#ifndef EXTERN 
    #define EXTERN extern 
#endif 


typedef enum {START, STOP, STARTMESSEN, MESSEN1, MESSEN2, FREIGEBEN} 
     sd_state_t; 



EXTERN volatile sd_state_t SD_STATE; 

EXTERN volatile unsigned char gFlag_AdcReady = 0; 

EXTERN volatile unsigned char gFlag_SDAktiv = 0; 

EXTERN volatile unsigned char gCnt_SD = 0; 



#ifdef __cplusplus 
extern "C" { 
#endif /* __cplusplus */ 



#ifdef __cplusplus 
} 
#endif /* __cplusplus */ 

//tmr1.c 

#include <xc.h> 
#include "tmr1.h" 

#include "../globalVar.h" 

// ... 
// MCC-Generated standard code.. 
// ... 

void TMR1_DefaultInterruptHandler(void){ 
    // add your TMR1 interrupt custom code 
    // or set custom function using TMR1_SetInterruptHandler() 

    gCnt_SD++; 


    if (gCnt_SD == 180) 
    { 
     gFlag_SDAktiv = 1; 
    } 

#include <xc.h> 
#include "adc1.h" 
#include "mcc.h" 

#include "../globalVar.h" 

void ADC1_ISR(void) 
{ 
    // Clear the ADC interrupt flag 
    PIR1bits.ADIF = 0; 

    gFlag_AdcReady = 1; // Flag setzen, AD-Wandlung abgeschlossen 



} 

CLEAN SUCCESSFUL (total time: 125ms) 
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf 
make[1]: Entering directory 'C:/Users/AS/Desktop/MPLAB_Projekte/MINIMAL_CO_Sensor_V04.X' 
make -f nbproject/Makefile-default.mk dist/default/production/MINIMAL_CO_Sensor_V04.X.production.hex 
make[2]: Entering directory 'C:/Users/AS/Desktop/MPLAB_Projekte/MINIMAL_CO_Sensor_V04.X' 
"C:\Program Files (x86)\Microchip\xc8\v1.42\bin\xc8.exe" --pass1 --chip=12F1572 -Q -G --double=24 --float=24 --opt=+asm,+asmfile,-speed,+space,-debug,-local --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,-osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -obuild/default/production/mcc_generated_files/mcc.p1 mcc_generated_files/mcc.c 
"C:\Program Files (x86)\Microchip\xc8\v1.42\bin\xc8.exe" --pass1 --chip=12F1572 -Q -G --double=24 --float=24 --opt=+asm,+asmfile,-speed,+space,-debug,-local --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,-osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -obuild/default/production/mcc_generated_files/interrupt_manager.p1 mcc_generated_files/interrupt_manager.c 
"C:\Program Files (x86)\Microchip\xc8\v1.42\bin\xc8.exe" --pass1 --chip=12F1572 -Q -G --double=24 --float=24 --opt=+asm,+asmfile,-speed,+space,-debug,-local --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,-osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -obuild/default/production/mcc_generated_files/pin_manager.p1 mcc_generated_files/pin_manager.c 
"C:\Program Files (x86)\Microchip\xc8\v1.42\bin\xc8.exe" --pass1 --chip=12F1572 -Q -G --double=24 --float=24 --opt=+asm,+asmfile,-speed,+space,-debug,-local --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,-osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -obuild/default/production/mcc_generated_files/tmr0.p1 mcc_generated_files/tmr0.c 
"C:\Program Files (x86)\Microchip\xc8\v1.42\bin\xc8.exe" --pass1 --chip=12F1572 -Q -G --double=24 --float=24 --opt=+asm,+asmfile,-speed,+space,-debug,-local --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,-osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -obuild/default/production/mcc_generated_files/tmr1.p1 mcc_generated_files/tmr1.c 
"C:\Program Files (x86)\Microchip\xc8\v1.42\bin\xc8.exe" --pass1 --chip=12F1572 -Q -G --double=24 --float=24 --opt=+asm,+asmfile,-speed,+space,-debug,-local --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,-osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -obuild/default/production/main.p1 main.c 
"C:\Program Files (x86)\Microchip\xc8\v1.42\bin\xc8.exe" --pass1 --chip=12F1572 -Q -G --double=24 --float=24 --opt=+asm,+asmfile,-speed,+space,-debug,-local --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,-osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -obuild/default/production/mcc_generated_files/adc1.p1 mcc_generated_files/adc1.c 
mcc_generated_files/../globalVar.h:17: warning: (339) initializer in extern declaration 
mcc_generated_files/../globalVar.h:19: warning: (339) initializer in extern declaration 
mcc_generated_files/../globalVar.h:21: warning: (339) initializer in extern declaration 
globalVar.h:17: warning: (339) initializer in extern declaration 
globalVar.h:19: warning: (339) initializer in extern declaration 
mcc_generated_files/tmr1.c:87: warning: (373) implicit signed to unsigned conversion 
globalVar.h:21: warning: (339) initializer in extern declaration 
mcc_generated_files/tmr1.c:96: warning: (2030) a data pointer cannot be used to hold the address of a function 
pointer to function with no arguments returning void -> pointer to void 
mcc_generated_files/tmr1.c:118: warning: (373) implicit signed to unsigned conversion 
mcc_generated_files/tmr1.c:179: warning: (2029) a function pointer cannot be used to hold the address of data 
pointer to void -> pointer to function with no arguments returning void 
mcc_generated_files/../globalVar.h:17: warning: (339) initializer in extern declaration 
mcc_generated_files/../globalVar.h:19: warning: (339) initializer in extern declaration 
mcc_generated_files/../globalVar.h:21: warning: (339) initializer in extern declaration 
mcc_generated_files/adc1.c:113: warning: (373) implicit signed to unsigned conversion 
mcc_generated_files/adc1.c:119: warning: (373) implicit signed to unsigned conversion 
mcc_generated_files/adc1.c:140: warning: (373) implicit signed to unsigned conversion 
mcc_generated_files/../globalVar.h:17: warning: (339) initializer in extern declaration 
mcc_generated_files/../globalVar.h:19: warning: (339) initializer in extern declaration 
mcc_generated_files/../globalVar.h:21: warning: (339) initializer in extern declaration 
mcc_generated_files/tmr0.c:75: warning: (373) implicit signed to unsigned conversion 
mcc_generated_files/tmr0.c:90: warning: (2030) a data pointer cannot be used to hold the address of a function 
pointer to function with no arguments returning void -> pointer to void 
mcc_generated_files/tmr0.c:133: warning: (2029) a function pointer cannot be used to hold the address of data 
pointer to void -> pointer to function with no arguments returning void 
"C:\Program Files (x86)\Microchip\xc8\v1.42\bin\xc8.exe" --chip=12F1572 -G -mdist/default/production/MINIMAL_CO_Sensor_V04.X.production.map --double=24 --float=24 --opt=+asm,+asmfile,-speed,+space,-debug,-local --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,-osccal,-resetbits,-download,-stackcall,+clib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s"  --memorysummary dist/default/production/memoryfile.xml -odist/default/production/MINIMAL_CO_Sensor_V04.X.production.elf build/default/production/mcc_generated_files/adc1.p1 build/default/production/mcc_generated_files/mcc.p1 build/default/production/mcc_generated_files/pin_manager.p1 build/default/production/mcc_generated_files/interrupt_manager.p1 build/default/production/mcc_generated_files/tmr1.p1 build/default/production/mcc_generated_files/tmr0.p1 build/default/production/main.p1  
Microchip MPLAB XC8 C Compiler (Free Mode) V1.42 
Build date: Apr 12 2017 
Part Support Version: 1.42 
Copyright (C) 2017 Microchip Technology Inc. 
License type: Node Configuration 

:: warning: (1273) Omniscient Code Generation not available in Free mode 
mcc_generated_files/adc1.c:103: advisory: (1510) non-reentrant function "_ADC1_StartConversion" appears in multiple call graphs and has been duplicated by the compiler 
mcc_generated_files/adc1.c:95: warning: (520) function "_ADC1_SelectChannel" is never called 
mcc_generated_files/adc1.c:110: warning: (520) function "_ADC1_IsConversionDone" is never called 
mcc_generated_files/adc1.c:116: warning: (520) function "_ADC1_GetConversionResult" is never called 
mcc_generated_files/adc1.c:122: warning: (520) function "_ADC1_GetConversion" is never called 
mcc_generated_files/pin_manager.c:89: warning: (520) function "_PIN_MANAGER_IOC" is never called 
mcc_generated_files/tmr1.c:108: warning: (520) function "_TMR1_StopTimer" is never called 
mcc_generated_files/tmr1.c:114: warning: (520) function "_TMR1_ReadTimer" is never called 
mcc_generated_files/tmr1.c:123: warning: (520) function "_TMR1_WriteTimer" is never called 
mcc_generated_files/tmr1.c:145: warning: (520) function "_TMR1_Reload" is never called 
mcc_generated_files/tmr1.c:152: warning: (520) function "_TMR1_StartSinglePulseAcquisition" is never called 
mcc_generated_files/tmr1.c:157: warning: (520) function "_TMR1_CheckGateValueStatus" is never called 
mcc_generated_files/tmr0.c:94: warning: (520) function "_TMR0_ReadTimer" is never called 
mcc_generated_files/tmr0.c:103: warning: (520) function "_TMR0_WriteTimer" is never called 
mcc_generated_files/tmr0.c:109: warning: (520) function "_TMR0_Reload" is never called 
Non line specific message:: warning: (2028) external declaration for identifier "_SD_STATE" doesn't indicate storage location 
:0: error: (499) undefined symbol: 
    _SD_STATE(dist/default/production\MINIMAL_CO_Sensor_V04.X.production.obj) 
(908) exit status = 1 
nbproject/Makefile-default.mk:227: recipe for target 'dist/default/production/MINIMAL_CO_Sensor_V04.X.production.hex' failed 
make[2]: Leaving directory 'C:/Users/AS/Desktop/MPLAB_Projekte/MINIMAL_CO_Sensor_V04.X' 
nbproject/Makefile-default.mk:90: recipe for target '.build-conf' failed 
make[1]: Leaving directory 'C:/Users/AS/Desktop/MPLAB_Projekte/MINIMAL_CO_Sensor_V04.X' 
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed 
make[2]: *** [dist/default/production/MINIMAL_CO_Sensor_V04.X.production.hex] Error 1 
make[1]: *** [.build-conf] Error 2 
make: *** [.build-impl] Error 2 

BUILD FAILED (exit value 2, total time: 3s) 

je l'espère, vous pouvez me aider! Merci d'avance!

+0

Essayez de placer le volatile sd_state_t SD_STATE; dans main.c. Peut-être qu'il a besoin d'un endroit où placer l'objet. – imqqmi

Répondre

0

Vous déclarez 4 variables externat dans global.h

EXTERN volatile sd_state_t SD_STATE; 
EXTERN volatile unsigned char gFlag_AdcReady; 
EXTERN volatile unsigned char gFlag_SDAktiv; // = 0; The assign should go in .c 
EXTERN volatile unsigned char gCnt_SD; // = 0; 

Vous devez allouer de l'espace dans l'un de vos modules .c pour ces variables. C'est aussi là que va l'affectation initiale des valeurs. Ils seront mis à zéro automatiquement au démarrage.

volatile sd_state_t SD_STATE; 
volatile unsigned char gFlag_AdcReady; 
volatile unsigned char gFlag_SDAktiv; 
volatile unsigned char gCnt_SD;