|
|
View previous topic :: View next topic |
Author |
Message |
Wolf
Joined: 23 Sep 2011 Posts: 32
|
MCP251x.h Compile Error |
Posted: Sat Nov 23, 2013 8:42 pm |
|
|
I'm trying to compile this program using MPLAB X 1.60, I can't understand as to why this isn't compiling
Quote: |
CLEAN SUCCESSFUL (total time: 79ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/Documents and Settings/Administrator/Desktop/CAN Node/CANNode.X'
make -f nbproject/Makefile-default.mk dist/default/production/CANNode.X.production.hex
make[2]: Entering directory `C:/Documents and Settings/Administrator/Desktop/CAN Node/CANNode.X'
gnumkdir -p build/default/production
"C:\Program Files\PICC\CCSCON.exe" out="build/default/production" main.c +EXPORT +FD +DF +Y=9 +EA +DF +LN +T +A +M +J +EA +Z -P #__dsPIC30F4011__=TRUE +EXPORTD="build/default/production"
C:\Documents and Settings\Administrator\Desktop\CAN Node\CANNode.X\main.o ===> 0 Errors, 0 Warnings.
Build Successful.
gnumkdir -p build/default/production
"C:\Program Files\PICC\CCSCON.exe" out="build/default/production" can-mcp251x.c +EXPORT +FD +DF +Y=9 +EA +DF +LN +T +A +M +J +EA +Z -P #__dsPIC30F4011__=TRUE +EXPORTD="build/default/production"
C:\Program Files\PICC\drivers\can-mcp251x.h:86:1: Error#128 A #DEVICE required before this line
C:\Documents and Settings\Administrator\Desktop\CAN Node\CANNode.X\can-mcp251x.o ===> 1 Errors, 0 Warnings.
Build Failed.
gnumkdir -p dist/default/production
"C:\Program Files\PICC\CCSCON.exe" out="dist/default/production" +FD +DF LINK=CANNode.X.production.hex=build/default/production/main.o,build/default/production/can-mcp251x.o +Y=9 +EA +DF +LN +T +A +M +J +EA +Z -P
Unable to find: C:\Documents and Settings\Administrator\Desktop\CAN Node\CANNode.X\CANNode.X.production.hex.err
make[2]: Leaving directory `C:/Documents and Settings/Administrator/Desktop/CAN Node/CANNode.X'
make[1]: Leaving directory `C:/Documents and Settings/Administrator/Desktop/CAN Node/CANNode.X'
|
Code: |
#include <30F4011.h>
#DEVICE *=16 ICD=TRUE ADC=10
#fuses PR,FRC_PLL16,NOWDT
#use delay(clock=117.92M)
#use rs232(baud=9600,UART1A)
//#include <can-mcp2510.c>
#include <can-mcp251x.c>
#define GREEN_LED PIN_E4
#define YELLOW_LED PIN_E2
#define RED_LED PIN_E1
#define WRITE_register_C_ID 0x300
void main() {
unsigned int32 rx_id;
unsigned int8 rx_len,buffer[8];
struct rx_stat rxstat;
int1 a,b,c;
a = b = c = TRUE;
can_init();
while(TRUE) {
if(can_getd(rx_id, &buffer[0], rx_len, rxstat)) {
if(rx_id == WRITE_REGISTER_C_ID && buffer[0] == 0x1e) {
if(buffer[1] & 2) a = buffer[2];
if(buffer[1] & 4) b = buffer[2];
if(buffer[1] & 8) c = buffer[2];
output_bit(RED_LED,a);
output_bit(YELLOW_LED,b);
output_bit(GREEN_LED,c);
}
}
}
}
|
I put the #devices in the main am I missing something in this header file that should be there? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Sun Nov 24, 2013 2:03 am |
|
|
I suspect that looks like the classic 'Mplab files' error.
_Only_ the main program file, must be in the 'source files' part of the Mplab project. The .h files, and included .c files, must be in the 'header files' section. If these files are put into the 'source files' part, then Mplab tries to compile them on their own. Since they lack things like #defines, they won't then compile.
Best Wishes |
|
|
Wolf
Joined: 23 Sep 2011 Posts: 32
|
|
Posted: Sun Nov 24, 2013 2:08 am |
|
|
Well I just moved them, and that didn't fix the problem I still got the same error. I also tried it with the CCS compiler PCW and it also gives me the same error that Mplab is giving me |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1345
|
|
Posted: Sun Nov 24, 2013 1:56 pm |
|
|
In MPLABX, you have to right click on the files and set them to not be compilable. There is an option for it there somewhere, perhaps in the properties of the file. |
|
|
Wolf
Joined: 23 Sep 2011 Posts: 32
|
|
Posted: Sun Nov 24, 2013 2:27 pm |
|
|
Ya I found it, it had 2 different options...
I took a screen shot to show if this is what you ment, but going through those options still gave me compiler problems. Infact the same problem still exists. Also, if just on a thought, if I exclude that header file from the compile procedures, then wouldn't it not allow the CAN features of the MCP2515 chip to not function?
After Message Edit:
Ok I bypassed that error by also making the .c file excluded from build, but my other question still stands, if I don't include those functions in the build, then how am I going to make the functions of this chip work if the commands to run that MCP chip aren't compounded into the program? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Sun Nov 24, 2013 3:31 pm |
|
|
They are still included.
The #include in the main code _includes_ these files, and they are then compiled _as part_ of the main code.
The point about the MPLAB option is it allows you to compile things 'on their own' (this can be done if the files are setup to do this, with suitable import/export options), which are then linked to the main code, but the default CCS setup, it to do a 'single pass' compile, with everything loaded for you by the main program.
Best Wishes |
|
|
Wolf
Joined: 23 Sep 2011 Posts: 32
|
|
Posted: Sun Nov 24, 2013 7:09 pm |
|
|
Well, it does seem to compile now...thank you |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|