• AVR Freaks

LockedCANOpen Library

Author
john.dammeyer
Super Member
  • Total Posts : 423
  • Reward points : 0
  • Joined: 2004/01/02 20:07:06
  • Status: offline
2014/09/01 09:36:50 (permalink)
0

CANOpen Library

I thought I'd finally make another attempt at using the MPLAB X environment again with the idea that eventually I'll be forced into it so I might as well dive in since  I have a small project for a client that shouldn't take longer than a week if I was using MPLAB 8 for the PIC18F2680.  In fact I started with MPLAB 8 and the Microchip CANOpen stack and an older project as the template.  The project compiles under MPLAB 8, runs as a CANOpen node and for this client I just need to change some of the application. 
First thing is import the application into the XC8 IDE.  Then compile.  First file is CO_CANDRV.C which includes CO_CANDRV.H which  includes <PIC18Cxxx.h> which looks like it's still tied to the MPLABC18 build environment as p18f2680.h
And somewhere in there then C:\Program Files (x86)\Microchip\xc8\v1.21\include\GenericTypeDefs.h is pulled in but after _BOOL has already been declared.
 

C:\Program Files (x86)\Microchip\xc8\v1.21\include\GenericTypeDefs.h:65: error: (1348) enum tag "_BOOL" redefined (from ../CANopenLib/../include/CO_TYPES.H:382)
make[2]: *** [build/default/production/_ext/2091052582/CO_CANDRV.p1] Error 1
C:\Program Files (x86)\Microchip\xc8\v1.21\include\GenericTypeDefs.h:65: error: (984) type redeclared
C:\Program Files (x86)\Microchip\xc8\v1.21\include\GenericTypeDefs.h:65: error: (1098) conflicting declarations for variable "FALSE" (../CANopenLib/../include/CO_TYPES.H:382)
nbproject/Makefile-default.mk:259: recipe for target 'build/default/production/_ext/2091052582/CO_CANDRV.p1' failed

 
#ifndef _BOOL
typedef enum _BOOL { FALSE = 0, TRUE } BOOL; /* Undefined size */
#define _BOOL _BOOL
#endif
typedef enum _BIT { CLEAR = 0, SET } BIT;

 
So what would be the next step.  Is there a way to use the old C compiler and just the new MPLAB X IDE although why I'd want to I'm also not sure.  Is there a version of the AN945 stack that compiles under MPLABX.  I currently have products using both the PIC18F2680 and dsPIC30F5011 and was thinking about a new one with one of the PIC32s but since I also have products with Freescale processors and the kVaser CANOpen stack I'm not sure the MPLABX IDE is even worth the effort.
 
#1
Jim Nickerson
User 452
  • Total Posts : 6736
  • Reward points : 0
  • Joined: 2003/11/07 12:35:10
  • Location: San Diego, CA
  • Status: offline
Re: CANOpen Library 2014/09/01 10:17:43 (permalink)
0
I have shifted my development away from MpLab to X entirely.
Yes you can use C18 from within X.
You might start that way just to get it compiling under X ( I did ).
Then removing/replacing "PIC18Cxxx.h" with "xc.h" etc.
I am liking the PIC32MX.
#2
john.dammeyer
Super Member
  • Total Posts : 423
  • Reward points : 0
  • Joined: 2004/01/02 20:07:06
  • Status: offline
Re: CANOpen Library 2014/09/02 09:41:00 (permalink)
0
Ah.  Knowing it's possible has turned it into a successful challenge.  Code now compiles with C18 inside X. Thank you.
Can you point me to a document explaining xc.h verses PIC18Cxxx.h?  Is the xc.h a general replacement include file for all processor families?
I have a couple of PIC32 kits, Explorer 16, dsPIC kits and lots of PICTail boards.  I've written code for the PIC32 that receives the E1.31 (Ethernet DMX-512A) UDP packets and translates them to RS485 DMX-512A and my own CAN bus light show protocol.  But so far nothing's made it past the prototype stage.
#3
Jim Nickerson
User 452
  • Total Posts : 6736
  • Reward points : 0
  • Joined: 2003/11/07 12:35:10
  • Location: San Diego, CA
  • Status: offline
Re: CANOpen Library 2014/09/02 10:02:01 (permalink)
+1 (1)
Yes "xc.h"
You might open up "xc.h" and have a look, I use it to find the include files of interest. 

#ifndef _XC_H_
#define _XC_H_
#ifdef __XC8
#include <htc.h>
#endif
#endif //_XC_H

And following it we get to htc.h, and so on, at least for xc8 and it is similar for xc32.
 
 
#4
Jump to:
© 2020 APG vNext Commercial Version 4.5