【发布时间】:2017-09-22 19:44:39
【问题描述】:
我正在使用 PIC18F45K20 从 25Mhz 晶振接收外部振荡,而不是使用内部时钟。但是,我在代码中包含什么以将此外部振荡器设置为输入(我假设 PIC 设备上的 OSC1)?以下是我在 .h 文件中的典型配置编译指示。
// CONFIG1H
#pragma config FOSC = HSPLL
#pragma config FCMEN = OFF
#pragma config IESO = OFF
// CONFIG2L
#pragma config PWRT = OFF
#pragma config BOREN = SBORDIS
#pragma config BORV = 18
// CONFIG2H
#pragma config WDTEN = OFF
#pragma config WDTPS = 32768
// CONFIG3H
#pragma config CCP2MX = PORTC
#pragma config PBADEN = ON
#pragma config LPT1OSC = OFF
#pragma config HFOFST = ON
#pragma config MCLRE = ON
// CONFIG4L
#pragma config STVREN = ON
#pragma config LVP = OFF
#pragma config XINST = OFF
// CONFIG5L
#pragma config CP0 = OFF
#pragma config CP1 = OFF
#pragma config CP2 = OFF
#pragma config CP3 = OFF
// CONFIG5H
#pragma config CPB = OFF
#pragma config CPD = OFF
// CONFIG6L
#pragma config WRT0 = OFF
#pragma config WRT1 = OFF
#pragma config WRT2 = OFF
#pragma config WRT3 = OFF
// CONFIG6H
#pragma config WRTC = OFF
#pragma config WRTB = OFF
#pragma config WRTD = OFF
// CONFIG7L
#pragma config EBTR0 = OFF
#pragma config EBTR1 = OFF
#pragma config EBTR2 = OFF
#pragma config EBTR3 = OFF
// CONFIG7H
#pragma config EBTRB = OFF
#define _XTAL_FREQ 25000000
#ifndef MCC_H
#define MCC_H
#include <xc.h>
#include "pin_manager.h"
#include <stdint.h>
#include <stdbool.h>
#include "eusart.h"
但是,当我尝试构建它时,我得到了错误:
mcc_generated_files/mcc.h:46: error: (1389) attempt to reprogram configuration setting "FOSC" with HSPLL (is HSPLL)
mcc_generated_files/mcc.h:68: error: (1389) attempt to reprogram configuration setting "LVP" with OFF (is OFF)
我做错了吗?这些错误甚至意味着什么?我要做的就是从使用内部时钟更改为使用外部 25Mhz 晶体。
【问题讨论】:
标签: ide pic microchip mplab pic18