我使用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晶体。
答案 0 :(得分:0)
行:#pragma config FOSC = HSPLL
错误,因为最大CPU频率为64 MHz。 PLL选项将频率乘以16,因此对于25 Mhz晶振仅使用HS
选项。
行:#pragma config LVP = OFF
,你正在使用什么样的程序员?如果您在Single-Supply
模式下对设备进行编程,则无法关闭此模式。