编译器是PICC 程序有点大,分模块写的,编译时CRC校验定义的表格有问题,帖一下相关的:
/**************** CRC.h **************************/
#ifdef CRC_GLOBALS #define CRC_EXT #else #define CRC_EXT extern #endif
CRC_EXT const uchar CRCHi[256]={....}; //数据省略 CRC_EXT const uchar CRCLo[256]={....};
CRC_EXT uint CRC16(bank2 uchar *puchMsg, uchar usDataLen );
/******************************************************/
/******************** CRC.c ***************************/ /****************就是个CRC校验的函数没什么说的*********/ #define CRC_GLOBALS #include"includes.h" //这个文件已经包含了CRC.h uint CRC16(bank2 uchar *puchMsg, uchar usDataLen ) /* The function returns the CRC as a unsigned short type */ { uchar uchCRCHi=0xFF; /* high byte of CRC initialized */ uchar uchCRCLo=0xFF; /* low byte of CRC initialized */ uint uIndex; /* will index into CRC lookup table */ const uchar *PHi; const uchar *PLo; PHi=CRCHi; PLo=CRCLo; while(usDataLen--) /* pass through message buffer */ { uIndex=uchCRCLo^(*puchMsg++); /* calculate the CRC */ //uchCRCLo=uchCRCHi^CRCHi[uIndex]; uchCRCLo=uchCRCHi^(*(PHi+uIndex)); //uchCRCHi=CRCLo[uIndex]; uchCRCHi=*(PLo+uIndex); } return (uchCRCHi<<8|uchCRCLo); }
/**************************************************************/
我在另外两个.C模块中调用上面CRC校验函数 /********************* RTU.c *********************************/ #define RTU_GLOBALS #include"includes.h" .... void RTUReceive(void) { .... CRCTmp1=CRC16(ptr1, DataLen1 ); .... } .... /******************************************************************/
/************************* RTUSlave.c **************************/ #define RTUSlave_GLOBALS #include"includes.h" ... void RepuCheck(void) { .... CRCTmp2=CRC16(ptr2, DataLen2 ); .... } ... /*******************************************************************/
就在这两个地方用了,因为我原来在51单片机上写没什么问题的,可是在pic上编译有问题,我用pic16f877a : Error [482] ; . symbol "_CRCHi" is defined more than once in "ApplMain.obj" Error [482] ; . symbol "_CRCLo" is defined more than once in "ApplMain.obj" Error [482] ; . symbol "_CRCHi" is defined more than once in "ApplMain.obj" Error [482] ; . symbol "_CRCLo" is defined more than once in "ApplMain.obj" Error [482] ; . symbol "_CRCHi" is defined more than once in "ApplMain.obj" Error [482] ; . symbol "_CRCLo" is defined more than once in "ApplMain.obj" Error [482] ; . symbol "_CRCHi" is defined more than once in "ApplMain.obj" Error [482] ; . symbol "_CRCLo" is defined more than once in "ApplMain.obj" Error [482] ; . symbol "_CRCHi" is defined more than once in "ApplMain.obj" Error [482] ; . symbol "_CRCLo" is defined more than once in "ApplMain.obj" Error [482] ; . symbol "_CRCHi" is defined more than once in "ApplMain.obj" Error [482] ; . symbol "_CRCLo" is defined more than once in "ApplMain.obj" ...
我实在想不出那里把它重定义了,好象语法没错误(提示是"_CRCHi"不是"CRCHi")
谢谢各位了,第一用pic |