1. function redefined错误
使用:pic16f636, hitech c, mplab x
解决办法:Headers should only contain #defines and C declarations. They should never NEVER *N*E*V*E*R* create any variables, functions or any other object that
allocates actual storage.
Global variables and functions need to be defined once only in a C file, not in a header. OTOH their extern declaration that makes them visible across the whole project needs to go into a header that can
be included by all C files.
PIC specific: Your CONFIG (for either the __CONFIG() or #pragma CONFIG forms) must be in a single C file, not in a header. The same goes for any ID locations or other compile time pre-loading of FLASH or
EEPROM.
DON'T include C files - EVER!. The include guard only protects you against multiple inclusion of a header i.e. if
my_hardware.h and my_main.h both need to include htc.h, the include guard in htc.h silently stop it getting included twice by any of my C files. It will do you NO GOOD WHATSOEVER wrapped round a C file that is compiled separately elsewhere.
2. error: can't find 0x6 words for psect "idloc" in class "IDLOC" (largest unused contiguous range 0x4)
使用:pic16f636, hitech c, mplab x
出错行:__IDLOC(0x0100); // define ID locations
解决办法:
Some devices will permit programming up to seven bits within each ID location. To program
the full seven bits, the regular __IDLOC() macro is not suitable. For this situation,
the __IDLOC7(a,b,c,d) macro is available. The parameters a to d are the
values to be programmed. The values can be entered in either decimal or hexadecimal
format, such as:
__IDLOC7(0x7f,1,70,0x5a);
即使用__IDLOC7才正确
3. conflicting
declarations for variable
使用:pic16f636,
hitech c, mplab x
描述如下:When I
call functions, I get compiler error 1098 - conflicting declarations for variable "*". I've checked and rechecked the routines in the .c file as well as the function prototypes in the .h file to no
end. All of them appear to match. Periodically I have also gotten the "function declared implicit int" warning as well, yet none of the functions are defined as an int.
解决办法:在调用函数的文件中将被调用的函数声明文件包括进去。
You
may need to add
#include "XXX.h"
also to the other C files
4.
Unable to resolve identifier __delay_ms
使用:pic18f2680,
hitech c, mplab x
问题描述:but
I have this error : Unable to resolve identifier __delay_ms
when I use the __delay_ms functions.
The code compile fine, but the debugger bug.
解决办法:__delay_ms()
is a #defined macro that invokes the underlying _delay() function, which is itself rather special as it is (usually ?) generated inline according to the delay specified.
It sounds like for some reason the 'magic' is not happening.
To
get rid of the ugly red exclamation mark I had to define the macro in the file I used it, like this:
#ifndef _XTAL_FREQ
#define
_XTAL_FREQ 4000000 //4Mhz FRC internal osc
#define __delay_us(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000000.0)))
#define __delay_ms(x) _delay((unsigned long)((x)*(_XTAL_FREQ/4000.0)))
#endif
5.
Cannot program a production build to a debug header.
使用:mplab x, pickit3
解决办法:选择Project Properties->Conf:[default]->Supported Debug Header: (Required)->None即可
6. Target device was not found. You must connect to a target device to use PICkit 3.
使用:mplab x, pickit3
解决办法(之一):选择Project Properties->Conf:[default]->PICkit 3->Option categories->Power,勾选Power target circuit from PICkit3.
7.error: conflicting declarations for variable
使用:mplab x, pickit3
解决办法:查看是否将函数声明到头文件里,头文件是否加#ifdef