私はPICプログラミングの初心者です。 This video私は最初のプログラムをコーディングしていました。PIC18F2220 LED点滅プログラムエラー
これは私が書いたコードです:
#include <stdio.h>
#include <stdlib.h>
#include "XC8.h"
void main(void)
{
TRISBbits.RB0 = 0;
OSCCON = 0x76;
while(1)
{
LATBbits.LATB0 = ~LATBbits.LATB0;
for (int countDelay=0; countDelay<20; countDelay++) __delay_ms(50);
}
}
そして、私のXC8.h
ヘッダファイルは以下のとおりです。
// PIC18F2220 Configuration Bit Settings
// 'C' source line config statements
// CONFIG1H
#pragma config OSC = RC // Oscillator Selection bits (External RC oscillator, CLKO function on RA6)
#pragma config FSCM = OFF // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
#pragma config IESO = OFF // Internal/External Switchover bit (Internal/External Switchover mode disabled)
// CONFIG2L
#pragma config PWRT = OFF // Power-up Timer enable bit (PWRT disabled)
#pragma config BOR = OFF // Brown-out Reset enable bit (Brown-out Reset disabled)
#pragma config BORV = 20 // Brown-out Reset Voltage bits (VBOR set to 2.0V)
// CONFIG2H
#pragma config WDT = ON // Watchdog Timer Enable bit (WDT enabled)
#pragma config WDTPS = 32768 // Watchdog Timer Postscale Select bits (1:32768)
// CONFIG3H
#pragma config CCP2MX = ON // CCP2 MUX bit (CCP2 input/output is multiplexed with RC1)
#pragma config PBAD = ANA // PORTB A/D Enable bit (PORTB<4:0> pins are configured as analog input channels on Reset)
#pragma config MCLRE = OFF // MCLR Pin Enable bit (MCLR disabled; RE3 input is enabled in 40-pin devices only (PIC18F4X20))
// CONFIG4L
#pragma config STVR = ON // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config LVP = ON // Single-Supply ICSP Enable bit (Single-Supply ICSP enabled)
// CONFIG5L
#pragma config CP0 = OFF // Code Protection bit (Block 0 (000200-0007FFh) not code-protected)
#pragma config CP1 = OFF // Code Protection bit (Block 1 (000800-000FFFh) not code-protected)
// CONFIG5H
#pragma config CPB = OFF // Boot Block Code Protection bit (Boot block (000000-0001FFh) is not code-protected)
#pragma config CPD = OFF // Data EEPROM Code Protection bit (Data EEPROM is not code-protected)
// CONFIG6L
#pragma config WRT0 = OFF // Write Protection bit (Block 0 (000200-0007FFh) not write-protected)
#pragma config WRT1 = OFF // Write Protection bit (Block 1 (000800-000FFFh) not write-protected)
// CONFIG6H
#pragma config WRTC = OFF // Configuration Register Write Protection bit (Configuration registers (300000-3000FFh) are not write-protected)
#pragma config WRTB = OFF // Boot Block Write Protection bit (Boot block (000000-0001FFh) is not write-protected)
#pragma config WRTD = OFF // Data EEPROM Write Protection bit (Data EEPROM is not write-protected)
// CONFIG7L
#pragma config EBTR0 = OFF // Table Read Protection bit (Block 0 (000200-0007FFh) not protected from table reads executed in other blocks)
#pragma config EBTR1 = OFF // Table Read Protection bit (Block 1 (000800-000FFFh) not protected from table reads executed in other blocks)
// CONFIG7H
#pragma config EBTRB = OFF // Boot Block Table Read Protection bit (Boot block (000000-0001FFh) is not protected from table reads executed in other blocks)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#define _XTAL_FREQ 8000000
チュートリアルで提供され、私はすべての手順に従ってきたが、私は次のように取得していますプログラムをビルドしようとするとエラーが発生します。
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'E:/Projects/Coding/MPLABX/Programming/XC8/XC8.X'
make -f nbproject/Makefile-default.mk dist/default/production/XC8.X.production.hex
make[2]: Entering directory 'E:/Projects/Coding/MPLABX/Programming/XC8/XC8.X'
"C:\Program Files (x86)\Microchip\xc8\v1.42\bin\xc8.exe" --pass1 --chip=18F2220 -Q -G --double=24 --float=24 --emi=wordwrite --opt=+asm,+asmfile,-speed,+space,-debug --addrqual=ignore --mode=free -P -N255 --warn=-3 --asmlist -DXPRJ_default=default --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,-download,+config,+clib,-plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s" -obuild/default/production/XC8.p1 XC8.c
XC8.c:15: error: (192) undefined identifier "TRISBbits"
XC8.c:15: error: (196) struct/union required
XC8.c:16: error: (192) undefined identifier "OSCCON"
XC8.c:20: error: (192) undefined identifier "LATBbits"
XC8.c:20: error: (196) struct/union required
XC8.c:20: error: (196) struct/union required
XC8.c:22: warning: (361) function declared implicit int
(908) exit status = 1
nbproject/Makefile-default.mk:100: recipe for target 'build/default/production/XC8.p1' failed
make[2]: Leaving directory 'E:/Projects/Coding/MPLABX/Programming/XC8/XC8.X'
nbproject/Makefile-default.mk:84: recipe for target '.build-conf' failed
make[1]: Leaving directory 'E:/Projects/Coding/MPLABX/Programming/XC8/XC8.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[2]: *** [build/default/production/XC8.p1] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 467ms)
希望しています。クエリに十分な入力を追加しました。私はこのセクションの初心者ですので、お気軽に詳しい情報をお尋ねください。
がコードとその動作を更新しました。ありがとうございます – vt673
@AndreKampling [礼儀正しくない...](https://meta.stackoverflow.com/a/266312/2410359) – chux
@chuc:あなたのヒントありがとうございます。私は前にそれを知らないし、もう一度やりません。 –