c - #包括不接受
问题描述
我正在尝试对 PIC 微控制器进行编程,但是,每次我尝试包含 <xc.h> 时,我都会收到相同的错误,“未解决包含文件内部”。
这是我正在尝试的:
#include <stdio.h>
#include "Header.h"
#define _XTAL_FREQ 4000000
int main(void)
{
}
请注意,#include "Header.h" 内部是我的 #pragma 和 #include <xc.h>,它们一直被识别为错误。有谁知道为什么 #include <xc.h> 一直这样失败?我也尝试将它直接包含在源文件中,但没有任何改变。
根据要求,我包含了头文件的内容,“Header.h”(多么有创意),我不建议阅读所有#pragma,它非常狭窄:
// PIC24EP32MC202 Configuration Bit Settings
// 'C' source line config statements
// FICD
#pragma config ICS = PGD1 // ICD Communication Channel Select bits (Communicate on PGEC1 and PGED1)
#pragma config JTAGEN = OFF // JTAG Enable bit (JTAG is disabled)
// FPOR
#pragma config ALTI2C1 = OFF // Alternate I2C1 pins (I2C1 mapped to SDA1/SCL1 pins)
#pragma config ALTI2C2 = OFF // Alternate I2C2 pins (I2C2 mapped to SDA2/SCL2 pins)
#pragma config WDTWIN = WIN25 // Watchdog Window Select bits (WDT Window is 25% of WDT period)
// FWDT
#pragma config WDTPOST = PS32768 // Watchdog Timer Postscaler bits (1:32,768)
#pragma config WDTPRE = PR128 // Watchdog Timer Prescaler bit (1:128)
#pragma config PLLKEN = ON // PLL Lock Enable bit (Clock switch to PLL source will wait until the PLL lock signal is valid.)
#pragma config WINDIS = OFF // Watchdog Timer Window Enable bit (Watchdog Timer in Non-Window mode)
#pragma config FWDTEN = ON // Watchdog Timer Enable bit (Watchdog timer always enabled)
// FOSC
#pragma config POSCMD = NONE // Primary Oscillator Mode Select bits (Primary Oscillator disabled)
#pragma config OSCIOFNC = OFF // OSC2 Pin Function bit (OSC2 is clock output)
#pragma config IOL1WAY = ON // Peripheral pin select configuration (Allow only one reconfiguration)
#pragma config FCKSM = CSDCMD // Clock Switching Mode bits (Both Clock switching and Fail-safe Clock Monitor are disabled)
// FOSCSEL
#pragma config FNOSC = FRCDIVN // Oscillator Source Selection (Internal Fast RC (FRC) Oscillator with postscaler)
#pragma config PWMLOCK = ON // PWM Lock Enable bit (Certain PWM registers may only be written after key sequence)
#pragma config IESO = ON // Two-speed Oscillator Start-up Enable bit (Start up device with FRC, then switch to user-selected oscillator source)
// FGS
#pragma config GWRP = OFF // General Segment Write-Protect bit (General Segment may be written)
#pragma config GCP = OFF // General Segment Code-Protect bit (General Segment Code protect is Disabled)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#include <xc.h>
解决方案
这是你应该开始的方式:
#include <xc.h>
#include <stdio.h>
#include "Header.h"
#define _XTAL_FREQ 4000000
int main(void)
{
}
并#include <xc.h>
从您的文件中删除Header.h
推荐阅读
- reactjs - 执行历史记录(点)推送后 URL 被更改,但历史记录(点)位置(点)路径名在反应中保持不变
- android - E/ExoPlayerImplInternal:源错误 com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException:响应代码:403
- javascript - 用分号分割数组中的每个字符串
- flutter - 让用户改变比例的最佳方式是什么?
- arrays - 如何获取 Haskell UArray 的所有元素
- flutter - 如何混淆 Flutter 应用程序 ios?
- laravel - 社交登录后如何将用户重定向回预期路线?
- java - 滚动上的 Recycleview 在最后一个项目位置抛出 java.lang.IndexOutOfBoundsException
- html - 所有容器的高度相同 - Bootstrap 4
- bluetooth-lowenergy - 接收 BLE 信息并通过 TI CC2640R2F 上的 UART 传递信息