这是我的头文件代码。
标题文件名 16f877a.h
其代码获取from this link
我的文件名 led.c
#include "16f877a.h" //IC selection
#fuses XT, NOWDT, NOPROTECT, NOLVP
#use delay (clock =20000000) //clock 20MHz
void main(){
while(1){
output_B(0xff); //hex to binary output on port B
delay_us(500); // delay = 500 x clock period.
output_B(0x00);
delay_us(500);
}
}
这些文件位于相同文件夹
中/家庭/公司/文档/ CCPP / PIC / LedProject
我使用 UBUNTU 12.04 。 用 gcc 我编译了一个简单的hello world程序,它运行正常。 这是我在终端的命令历史记录
mkdir -p PIC/LedProject
cd PIC/LedProject/
gedit led.c
gcc -Wall -W -Werror led.c -o LedProC
这是我的错误。请帮我解决这个问题
In file included from led.c:1:0:
16f877a.h:91:0: error: ignoring #pragma maxram [-Werror=unknown-pragmas]
16f877a.h:99:0: error: ignoring #pragma memmap INDF_ADDR [-Werror=unknown-pragmas]
16f877a.h:100:0: error: ignoring #pragma memmap TMR0_ADDR [-Werror=unknown-pragmas]
16f877a.h:101:0: error: ignoring #pragma memmap PCL_ADDR [-Werror=unknown-pragmas]
16f877a.h:102:0: error: ignoring #pragma memmap STATUS_ADDR [-Werror=unknown-pragmas]
16f877a.h:103:0: error: ignoring #pragma memmap FSR_ADDR [-Werror=unknown-pragmas]
16f877a.h:104:0: error: ignoring #pragma memmap PORTA_ADDR [-Werror=unknown-pragmas]
16f877a.h:105:0: error: ignoring #pragma memmap PORTB_ADDR [-Werror=unknown-pragmas]
16f877a.h:106:0: error: ignoring #pragma memmap PORTC_ADDR [-Werror=unknown-pragmas]
16f877a.h:107:0: error: ignoring #pragma memmap PORTD_ADDR [-Werror=unknown-pragmas]
16f877a.h:108:0: error: ignoring #pragma memmap PORTE_ADDR [-Werror=unknown-pragmas]
16f877a.h:109:0: error: ignoring #pragma memmap PCLATH_ADDR [-Werror=unknown-pragmas]
16f877a.h:110:0: error: ignoring #pragma memmap INTCON_ADDR [-Werror=unknown-pragmas]
16f877a.h:111:0: error: ignoring #pragma memmap PIR1_ADDR [-Werror=unknown-pragmas]
16f877a.h:112:0: error: ignoring #pragma memmap PIR2_ADDR [-Werror=unknown-pragmas]
16f877a.h:113:0: error: ignoring #pragma memmap TMR1L_ADDR [-Werror=unknown-pragmas]
16f877a.h:114:0: error: ignoring #pragma memmap TMR1H_ADDR [-Werror=unknown-pragmas]
16f877a.h:115:0: error: ignoring #pragma memmap T1CON_ADDR [-Werror=unknown-pragmas]
16f877a.h:116:0: error: ignoring #pragma memmap TMR2_ADDR [-Werror=unknown-pragmas]
16f877a.h:117:0: error: ignoring #pragma memmap T2CON_ADDR [-Werror=unknown-pragmas]
16f877a.h:118:0: error: ignoring #pragma memmap SSPBUF_ADDR [-Werror=unknown-pragmas]
16f877a.h:119:0: error: ignoring #pragma memmap SSPCON_ADDR [-Werror=unknown-pragmas]
16f877a.h:120:0: error: ignoring #pragma memmap CCPR1L_ADDR [-Werror=unknown-pragmas]
16f877a.h:121:0: error: ignoring #pragma memmap CCPR1H_ADDR [-Werror=unknown-pragmas]
16f877a.h:122:0: error: ignoring #pragma memmap CCP1CON_ADDR [-Werror=unknown-pragmas]
16f877a.h:123:0: error: ignoring #pragma memmap RCSTA_ADDR [-Werror=unknown-pragmas]
16f877a.h:124:0: error: ignoring #pragma memmap TXREG_ADDR [-Werror=unknown-pragmas]
16f877a.h:125:0: error: ignoring #pragma memmap RCREG_ADDR [-Werror=unknown-pragmas]
16f877a.h:126:0: error: ignoring #pragma memmap CCPR2L_ADDR [-Werror=unknown-pragmas]
16f877a.h:127:0: error: ignoring #pragma memmap CCPR2H_ADDR [-Werror=unknown-pragmas]
16f877a.h:128:0: error: ignoring #pragma memmap CCP2CON_ADDR [-Werror=unknown-pragmas]
16f877a.h:129:0: error: ignoring #pragma memmap ADRESH_ADDR [-Werror=unknown-pragmas]
16f877a.h:130:0: error: ignoring #pragma memmap ADCON0_ADDR [-Werror=unknown-pragmas]
16f877a.h:131:0: error: ignoring #pragma memmap OPTION_REG_ADDR [-Werror=unknown-pragmas]
16f877a.h:132:0: error: ignoring #pragma memmap TRISA_ADDR [-Werror=unknown-pragmas]
16f877a.h:133:0: error: ignoring #pragma memmap TRISB_ADDR [-Werror=unknown-pragmas]
16f877a.h:134:0: error: ignoring #pragma memmap TRISC_ADDR [-Werror=unknown-pragmas]
16f877a.h:135:0: error: ignoring #pragma memmap TRISD_ADDR [-Werror=unknown-pragmas]
16f877a.h:136:0: error: ignoring #pragma memmap TRISE_ADDR [-Werror=unknown-pragmas]
16f877a.h:137:0: error: ignoring #pragma memmap PIE1_ADDR [-Werror=unknown-pragmas]
16f877a.h:138:0: error: ignoring #pragma memmap PIE2_ADDR [-Werror=unknown-pragmas]
16f877a.h:139:0: error: ignoring #pragma memmap PCON_ADDR [-Werror=unknown-pragmas]
16f877a.h:140:0: error: ignoring #pragma memmap SSPCON2_ADDR [-Werror=unknown-pragmas]
16f877a.h:141:0: error: ignoring #pragma memmap PR2_ADDR [-Werror=unknown-pragmas]
16f877a.h:142:0: error: ignoring #pragma memmap SSPADD_ADDR [-Werror=unknown-pragmas]
16f877a.h:143:0: error: ignoring #pragma memmap SSPSTAT_ADDR [-Werror=unknown-pragmas]
16f877a.h:144:0: error: ignoring #pragma memmap TXSTA_ADDR [-Werror=unknown-pragmas]
16f877a.h:145:0: error: ignoring #pragma memmap SPBRG_ADDR [-Werror=unknown-pragmas]
16f877a.h:146:0: error: ignoring #pragma memmap ADRESL_ADDR [-Werror=unknown-pragmas]
16f877a.h:147:0: error: ignoring #pragma memmap ADCON1_ADDR [-Werror=unknown-pragmas]
16f877a.h:148:0: error: ignoring #pragma memmap EEDATA_ADDR [-Werror=unknown-pragmas]
16f877a.h:149:0: error: ignoring #pragma memmap EEADR_ADDR [-Werror=unknown-pragmas]
16f877a.h:150:0: error: ignoring #pragma memmap EEDATH_ADDR [-Werror=unknown-pragmas]
16f877a.h:151:0: error: ignoring #pragma memmap EEADRH_ADDR [-Werror=unknown-pragmas]
16f877a.h:152:0: error: ignoring #pragma memmap EECON1_ADDR [-Werror=unknown-pragmas]
16f877a.h:153:0: error: ignoring #pragma memmap EECON2_ADDR [-Werror=unknown-pragmas]
16f877a.h:206:1: error: unknown type name ‘data’
16f877a.h:206:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before numeric constant
16f877a.h:207:1: error: unknown type name ‘sfr’
16f877a.h:207:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before numeric constant
16f877a.h:208:1: error: unknown type name ‘data’
16f877a.h:208:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before numeric constant
16f877a.h:209:1: error: unknown type name ‘sfr’
16f877a.h:209:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before numeric constant
16f877a.h:267:1: error: unknown type name ‘sbit’
16f877a.h:267:1: error: expected declaration specifiers or ‘...’ before ‘(’ token
16f877a.h:268:1: error: unknown type name ‘sbit’
16f877a.h:485:1: error: expected declaration specifiers or ‘...’ before ‘(’ token
16f877a.h:486:1: error: unknown type name ‘sbit’
16f877a.h:486:1: error: expected declaration specifiers or ‘...’ before ‘(’ token
led.c:2:2: error: invalid preprocessing directive #fuses
led.c:3:2: error: invalid preprocessing directive #use
led.c:4:6: error: return type of ‘main’ is not ‘int’ [-Werror=main]
led.c: In function ‘main’:
led.c:6:3: error: implicit declaration of function ‘output_B’ [-Werror=implicit-function-declaration]
led.c:7:3: error: implicit declaration of function ‘delay_us’ [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
bellvantage@BVPC00024:~/Documents/CCPP/PIC/LedProject$ mkdir -p PIC/LedProject
bellvantage@BVPC00024:~/Documents/CCPP/PIC/LedProject$ cd PIC/LedProject/
bellvantage@BVPC00024:~/Documents/CCPP/PIC/LedProject/PIC/LedProject$ gedit led.c
bellvantage@BVPC00024:~/Documents/CCPP/PIC/LedProject/PIC/LedProject$ gcc -Wall -W -Werror led.c -o LedProC
gcc: error: led.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
我将this blog称为我的电路
答案 0 :(得分:0)
您使用的源代码不是严格C
,而是包含许多预处理器命令的扩展程序,例如
#fuses XT, NOWDT, NOPROTECT, NOLVP
#use delay (clock =20000000) //clock 20MHz
这些用于配置PIC处理器。这种C
类似语言的编译器对
delay_us()
您使用的兼容C
编译器(gcc)不了解fuse,delay_us等,因此声明了许多错误。
如果你的目标是编程PIC - 我认为是这样,使用这种类型的C
,转到MicroChip,CCS或其他地方并获得他们的PIC C
编译器。
如果您的目标是在UBUNTU机器上使用gcc进行编程,请不要使用为PIC设计的代码。
BTW:可能存在可在UBUNTU上编译的PIC交叉编译器,但我不知道。搜索gcc PIC交叉编译器的问题,您可能会发现它已得到解答。