extern uint8_t var not recognized in MCC generated code when compiled

Author
brada
New Member
  • Total Posts : 14
  • Reward points : 0
  • Joined: 2011/08/17 14:55:50
  • Location: Spokane, WA
  • Status: offline
2017/10/12 11:35:33 (permalink)
0

extern uint8_t var not recognized in MCC generated code when compiled

I have a project that has MCC generated code in a subdirectory.  I want to access a variable that is declared in code in the parent directory.  Why is the extern declaration not recognized or accepted?
 
 
<parent dir>
file.c with uint8_t sensor_fail declaration
  uint8_t sensor_fail;
    <MCC Generated Files dir>
     pin_manager.c  (see below)
 
When I try to compile the MCC code, I get the following:
 
CLEAN SUCCESSFUL (total time: 51ms)
"C:\Program Files (x86)\Microchip\xc16\v1.32\bin\xc16-gcc.exe" mcc_generated_files/pin_manager.c -o build/default/production/mcc_generated_files/pin_manager.o -c -mcpu=24FJ128GA610 -MMD -MF "build/default/production/mcc_generated_files/pin_manager.o.d" -mno-eds-warn -g -omf=elf -DXPRJ_default=default -no-legacy-libc -O0 -msmart-io=1 -Wall -msfr-warn=off
nbproject/Makefile-default.mk:302: recipe for target 'build/default/production/mcc_generated_files/pin_manager.o' failed
mcc_generated_files/pin_manager.c:54:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'sensor_fail'
mcc_generated_files/pin_manager.c: In function '_IOCInterrupt':
mcc_generated_files/pin_manager.c:223:13: error: 'sensor_fail' undeclared (first use in this function)
mcc_generated_files/pin_manager.c:223:13: note: each undeclared identifier is reported only once for each function it appears in
make: *** [build/default/production/mcc_generated_files/pin_manager.o] Error 255
BUILD FAILED (exit value 2, total time: 455ms)
 
/**
  System Interrupts Generated Driver File

  @Company:
    Microchip Technology Inc.

  @File Name:
    pin_manager.c

  @Summary:
    This is the generated manager file for the MPLAB(c) Code Configurator device. This manager
    configures the pins direction, initial state, analog setting.
    The peripheral pin select, PPS, configuration is also handled by this manager.

  @Description:
    This source file provides implementations for MPLAB(c) Code Configurator interrupts.
    Generation Information :
        Product Revision : MPLAB(c) Code Configurator - 4.26
        Device : PIC24FJ128GA610
    The generated drivers are tested against the following:
        Compiler : XC16 1.32
        MPLAB : MPLAB X 3.61

    Copyright (c) 2013 - 2015 released Microchip Technology Inc. All rights reserved.

    Microchip licenses to you the right to use, modify, copy and distribute
    Software only when embedded on a Microchip microcontroller or digital signal
    controller that is integrated into your product or third party product
    (pursuant to the sublicense terms in the accompanying license agreement).

    You should refer to the license agreement accompanying this Software for
    additional information regarding your rights and obligations.

    SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
    EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
    MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
    IN NO EVENT SHALL MICROCHIP OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER
    CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR
    OTHER LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
    INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR
    CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF
    SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
    (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

*/


/**
    Section: Includes
*/
#include <xc.h>
#include "pin_manager.h"

extern uint8_t sensor_fail;

/**
    void PIN_MANAGER_Initialize(void)
*/
void PIN_MANAGER_Initialize(void)
{
    /****************************************************************************
     * Setting the Output Latch SFR(s)
     ***************************************************************************/
    LATA = 0x0012;
    LATB = 0x0000;
    LATC = 0x0000;
    LATD = 0x050A;
    LATE = 0x0000;
    LATF = 0x0124;
    LATG = 0x0000;

    /****************************************************************************
     * Setting the GPIO Direction SFR(s)
     ***************************************************************************/
    TRISA = 0x864C;
    TRISB = 0xFFFF;
    TRISC = 0x1000;
    TRISD = 0x7200;
    TRISE = 0x0000;
    TRISF = 0x104B;
    TRISG = 0x700F;

    /****************************************************************************
     * Setting the Weak Pull Up and Weak Pull Down SFR(s)
     ***************************************************************************/
    IOCPDA = 0x0000;
    IOCPDB = 0x0000;
    IOCPDC = 0x0000;
    IOCPDD = 0x0000;
    IOCPDE = 0x0000;
    IOCPDF = 0x0000;
    IOCPDG = 0x0000;
    IOCPUA = 0x0000;
    IOCPUB = 0x0000;
    IOCPUC = 0x0000;
    IOCPUD = 0x0000;
    IOCPUE = 0x0000;
    IOCPUF = 0x0000;
    IOCPUG = 0x0000;

    /****************************************************************************
     * Setting the Open Drain SFR(s)
     ***************************************************************************/
    ODCA = 0x0000;
    ODCB = 0x0000;
    ODCC = 0x0000;
    ODCD = 0x0002;
    ODCE = 0x0000;
    ODCF = 0x0000;
    ODCG = 0x0000;

    /****************************************************************************
     * Setting the Analog/Digital Configuration SFR(s)
     ***************************************************************************/
    ANSA = 0x0600;
    ANSB = 0x1FFC;
    ANSC = 0x0000;
    ANSD = 0x0000;
    ANSE = 0x0000;
    ANSG = 0x0000;


    /****************************************************************************
     * Set the PPS
     ***************************************************************************/
    __builtin_write_OSCCONL(OSCCON & 0xbf); // unlock PPS

    RPOR5bits.RP10R = 0x0008; //RF4->SPI1:SCK1OUT;
    RPINR18bits.U1RXR = 0x002A; //RD12->UART1:U1RX;
    RPOR2bits.RP5R = 0x0007; //RD15->SPI1:SDO1;
    RPOR11bits.RP22R = 0x0003; //RD3->UART1:U1TX;
    RPOR15bits.RP31R = 0x000D; //RF13->OC1:OC1;
    RPOR15bits.RP30R = 0x000F; //RF2->OC3:OC3;
    RPINR20bits.SDI1R = 0x002B; //RD14->SPI1:SDI1;
    RPINR3bits.T2CKR = 0x0020; //RF12->TMR2:T2CK;
    RPOR1bits.RP2R = 0x0005; //RD8->UART2:U2TX;
    RPINR19bits.U2RXR = 0x0023; //RA15->UART2:U2RX;

    __builtin_write_OSCCONL(OSCCON | 0x40); // lock PPS
    
    /****************************************************************************
     * Interrupt On Change for group IOCFA - flag
     ***************************************************************************/
    IOCFAbits.IOCFA6 = 0; // Pin : RA6
 
    /****************************************************************************
     * Interrupt On Change for group IOCNA - negative
     ***************************************************************************/
 IOCNAbits.IOCNA6 = 1; // Pin : RA6

    /****************************************************************************
     * Interrupt On Change for group IOCPA - positive
     ***************************************************************************/
 IOCPAbits.IOCPA6 = 0; // Pin : RA6

    /****************************************************************************
     * Interrupt On Change for group IOCFF - flag
     ***************************************************************************/
 IOCFFbits.IOCFF0 = 0; // Pin : RF0
 IOCFFbits.IOCFF1 = 0; // Pin : RF1

    /****************************************************************************
     * Interrupt On Change for group IOCNF - negative
     ***************************************************************************/
 IOCNFbits.IOCNF0 = 1; // Pin : RF0
 IOCNFbits.IOCNF1 = 1; // Pin : RF1

    /****************************************************************************
     * Interrupt On Change for group IOCPF - positive
     ***************************************************************************/
 IOCPFbits.IOCPF0 = 0; // Pin : RF0
 IOCPFbits.IOCPF1 = 0; // Pin : RF1

    /****************************************************************************
     * Interrupt On Change for group IOCFG - flag
     ***************************************************************************/
 IOCFGbits.IOCFG0 = 0; // Pin : RG0
 IOCFGbits.IOCFG1 = 0; // Pin : RG1
 IOCFGbits.IOCFG12 = 0; // Pin : RG12
 IOCFGbits.IOCFG13 = 0; // Pin : RG13
 IOCFGbits.IOCFG14 = 0; // Pin : RG14

    /****************************************************************************
     * Interrupt On Change for group IOCNG - negative
     ***************************************************************************/
 IOCNGbits.IOCNG0 = 1; // Pin : RG0
 IOCNGbits.IOCNG1 = 1; // Pin : RG1
 IOCNGbits.IOCNG12 = 1; // Pin : RG12
 IOCNGbits.IOCNG13 = 1; // Pin : RG13
 IOCNGbits.IOCNG14 = 1; // Pin : RG14

    /****************************************************************************
     * Interrupt On Change for group IOCPG - positive
     ***************************************************************************/
 IOCPGbits.IOCPG0 = 0; // Pin : RG0
 IOCPGbits.IOCPG1 = 0; // Pin : RG1
 IOCPGbits.IOCPG12 = 0; // Pin : RG12
 IOCPGbits.IOCPG13 = 0; // Pin : RG13
 IOCPGbits.IOCPG14 = 0; // Pin : RG14

    /****************************************************************************
     * Interrupt On Change for group PADCON - config
     ***************************************************************************/
 PADCONbits.IOCON = 1;

    IEC1bits.IOCIE = 1; // Enable IOCI interrupt
}



/* Interrupt service routine for the IOCI interrupt. */
void __attribute__ (( interrupt, no_auto_psv )) _IOCInterrupt ( void )
{
    if(IFS1bits.IOCIF == 1)
    {
        // Clear the flag
        IFS1bits.IOCIF = 0;
        // interrupt on change for group IOCAF
        if(IOCFAbits.IOCFA6 == 1)
        {
            IOCFAbits.IOCFA6 = 0;
            // Add handler code here for Pin - RA6 (ST5)
            sensor_fail |= 1<<4;
        }
        
        // interrupt on change for group IOCFF
        if(IOCFFbits.IOCFF0 == 1)
        {
            IOCFFbits.IOCFF0 = 0;
            // Add handler code here for Pin - RF0 (ST1)
            sensor_fail |= 1<<0;
        }
        if(IOCFFbits.IOCFF1 == 1)
        {
            IOCFFbits.IOCFF1 = 0;
            // Add handler code here for Pin - RF1 (ST2)
            sensor_fail |= 1<<1;
        }
        
        // interrupt on change for group IOCGF
        if(IOCFGbits.IOCFG0 == 1)
        {
            IOCFGbits.IOCFG0 = 0;
            // Add handler code here for Pin - RG0 (ST4)
            sensor_fail |= 1<<3;
        }
        if(IOCFGbits.IOCFG1 == 1)
        {
            IOCFGbits.IOCFG1 = 0;
            // Add handler code here for Pin - RG1 (ST3)
            sensor_fail |= 1<<2;
        }
        if(IOCFGbits.IOCFG12 == 1)
        {
            IOCFGbits.IOCFG12 = 0;
            // Add handler code here for Pin - RG12 (ST6)
            sensor_fail |= 1<<5;
        }
        if(IOCFGbits.IOCFG13 == 1)
        {
            IOCFGbits.IOCFG13 = 0;
            // Add handler code here for Pin - RG13 (ST7)
            sensor_fail |= 1<<6;
        }
        if(IOCFGbits.IOCFG14 == 1)
        {
            IOCFGbits.IOCFG14 = 0;
            // Add handler code here for Pin - RG14 (ST8)
            sensor_fail |= 1<<7;
        }
    }
}

#1

2 Replies Related Threads

    andersm
    Super Member
    • Total Posts : 2208
    • Reward points : 0
    • Joined: 2012/10/07 14:57:44
    • Location: 0
    • Status: offline
    Re: extern uint8_t var not recognized in MCC generated code when compiled 2017/10/12 11:43:05 (permalink)
    +3 (3)
    The stdint.h header is not included, so the uint8_t typedef is not visible to the compiler.
    #2
    brada
    New Member
    • Total Posts : 14
    • Reward points : 0
    • Joined: 2011/08/17 14:55:50
    • Location: Spokane, WA
    • Status: offline
    Re: extern uint8_t var not recognized in MCC generated code when compiled 2017/10/12 12:57:32 (permalink)
    0
    Well well!   Thanks so much.
    #3
    Jump to:
    © 2017 APG vNext Commercial Version 4.5