【问题标题】:Configure settings for external oscillator in MPLAB X IDE v3.65在 MPLAB X IDE v3.65 中配置外部振荡器的设置
【发布时间】: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


    【解决方案1】:

    行:#pragma config FOSC = HSPLL 错误,因为最大 CPU 频率为 64 MHz。 PLL 选项将频率乘以 16,因此对于 25 Mhz 晶振仅使用 HS 选项。

    Line:#pragma config LVP = OFF,你用的是什么编程器?如果您在Single-Supply 模式下对设备进行编程,则无法关闭此模式。

    【讨论】:

    • 当我将其更改为 HS 时,我仍然遇到相同的错误(尝试使用 HS(是 HS)重新编程...。我正在使用 PICkit3 对我的设备进行编程。但是,我可以' 甚至只是构建。打开 LVP 似乎摆脱了那个特定的错误。
    猜你喜欢
    • 2019-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-12
    • 1970-01-01
    • 2015-11-30
    相关资源
    最近更新 更多