• AVR Freaks

Hot!pic18f46k80.h file has redefinition of 'I2C_STOP' causing compile error

Author
popas
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2020/11/23 16:02:59
  • Location: 0
  • Status: offline
2020/12/04 13:45:09 (permalink)
5 (1)

pic18f46k80.h file has redefinition of 'I2C_STOP' causing compile error

MCC version:    4.0.2 which uses PIC18 MCUs Library Version 1.81.6. 
MPLAB X version:    5.45
Operating System and version:    Windows10 HOME 
Compiler version:    XC8 2.31 
Device name:    PIC18F46K80 which associates with Pack PIC 18F-K_DFP version 1.4.87.
Peripheral: MSSP I2C


I am a MPLABX newbie migrating from MPLAB 8x using MPASM (I know…) attempting to port code to C.
All seems well in auto generating project files using MCC for a EUSART peripheral, but for a separate project having only an MSSP I2C enabled there are compiler issues which I would NOT expect from the MPLABX project as it uses ALL MPLABX source files.
While the issue MIGHT be with XC8, I believe it is with the pic18f46k80.h file downloaded with MCC so I have posted this issue in MCC and not “MPLAB X IDE” or “MPLAB XC8” forums.
 
After Building here is the error message:
1 error generated.
In file included from main.c:44:
In file included from ./mcc_generated_files/mcc.h:55:
./mcc_generated_files/i2c_master.h:68:5: error: redefinition of 'I2C_STOP'
    I2C_STOP=1,
C:/Program Files/Microchip/MPLABX/v5.45/packs/Microchip/PIC18F-K_DFP/1.4.87/xc8\pic\include\proc\pic18f46k80.h:41144:41: note: previous definition is here
extern volatile __bit                   I2C_STOP            __at(0x7E3C);       // @ (0xFC7 * 8 + 4)
1 error generated.
(908) exit status = 1
 
It is noted that pic18f46k80.h has two definitions for I2C_STOP (line # shown); and here is where the issue originates.
35335   unsigned I2C_STOP               :1;
41144    extern volatile __bit                   I2C_STOP            __at(0x7E3C);      // @ (0xFC7 * 8 + 4)
 
Are my expectations correct that I should be able to:
  • Create a project using the pic18f46k80 as the target
  • Select the I2C peripheral using MCC
  • Generate to create the MCC files
  • Build main.c and not have any compile errors (the build will “do” nothing as there is no user code created yet).Have I missed something obvious? Can someone do a quick test to see if they have the same results to take my setup out of the picture?
  • #1

    2 Replies Related Threads

      Mysil
      Super Member
      • Total Posts : 4114
      • Reward points : 0
      • Joined: 2012/07/01 04:19:50
      • Location: Norway
      • Status: offline
      Re: pic18f46k80.h file has redefinition of 'I2C_STOP' causing compile error 2020/12/04 22:33:00 (permalink)
      5 (2)
      Hi,
       
      I have seen the same phenomen recently.
      It may  be different depending upon what version of XC8 is used, or maybe what DFP pack version is used.
       
      I do Not know why XC8 is suddenly defining symbols with prefix I2C,
      the name of the peripheral is MSSP, and the prefix for all registers have traditionally been SSPxxx,
      SSPSTAT,  SSPCON1, SSPCON2, ...
      or with a peripheral index:   SSP1xxx, like SSP1STAT, SSP1CON1, SSP1CON2, ...
       
      I do not know wether it is a mistake, or a deliberate change in the device support header files.
       
      Anyway, I found it easier to change the code generated by MCC, than messing with device header files belonging to the compiler.
       
      I did change the enumeration symbol in i2c_master.h   from I2C_STOP   to I2C_STOP_O,
      for  Operation return code,
      and did a search for where the symbol was used.
       
          Mysil
      post edited by Mysil - 2020/12/04 22:34:28
      #2
      Equinoxin
      New Users
      • Total Posts : 61
      • Reward points : 0
      • Status: offline
      Re: pic18f46k80.h file has redefinition of 'I2C_STOP' causing compile error 2021/01/15 16:47:37 (permalink)
      0
      Please log this as a bug in the ticketing system if you have confirmed it- https://microchipsupport.force.com/s/
      #3
      Jump to:
      © 2021 APG vNext Commercial Version 4.5