在学习PIC16F15345这颗MCU的时候,一开始就遇到难题,程序都不能正常进入debug
环境:MPLAB X IDE 5.45
硬件:PIC16F15345
烧录器:PICkit3
自己新建了一个工程,写了一个简单的LED闪烁功能,配置字也配置了,编译无错后下载,程序可以下载并运行。然后尝试进debug调试,会报错:该器件没有准备好调试。但并不是每次都会报错,时好时坏,大概率是会报错进不了debug的。
The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x7ff
configuration memory
Programming/Verify complete
The target device is not ready for debugging. Please check your configuration bit settings and program the device before proceeding. The most common causes for this failure are oscillator and/or PGC/PGD settings.
代码如下:各位大佬能否帮忙看看是哪里的问题,已经搞了两三天了,都不能正常进debug,万分感谢!
#include <xc.h>
#pragma config FEXTOSC = OFF // External Oscillator mode selection bits->Oscillator not enabled
#pragma config RSTOSC = HFINT1 // Power-up default value for COSC bits->HFINTOSC (1MHz)
#pragma config CLKOUTEN = OFF // Clock Out Enable bit->CLKOUT function is disabled; i/o or oscillator function on OSC2
#pragma config CSWEN = ON // Clock Switch Enable bit->Writing to NOSC and NDIV is allowed
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable bit->FSCM timer enabled
// CONFIG2
#pragma config MCLRE = ON // Master Clear Enable bit->MCLR pin is Master Clear function
#pragma config PWRTE = OFF // Power-up Timer Enable bit->PWRT disabled
#pragma config LPBOREN = OFF // Low-Power BOR enable bit->ULPBOR disabled
#pragma config BOREN = ON // Brown-out reset enable bits->Brown-out Reset Enabled, SBOREN bit is ignored
#pragma config BORV = LO // Brown-out Reset Voltage Selection->Brown-out Reset Voltage (VBOR) set to 1.9V on LF, and 2.45V on F Devices
#pragma config ZCD = OFF // Zero-cross detect disable->Zero-cross detect circuit is disabled at POR.
#pragma config PPS1WAY = ON // Peripheral Pin Select one-way control->The PPSLOCK bit can be cleared and set only once in software
#pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable bit->Stack Overflow or Underflow will cause a reset
// CONFIG3
#pragma config WDTCPS = WDTCPS_31 // WDT Period Select bits->Divider ratio 1:65536; software control of WDTPS
#pragma config WDTE = OFF // WDT operating mode->WDT Disabled, SWDTEN is ignored
#pragma config WDTCWS = WDTCWS_7 // WDT Window Select bits->window always open (100%); software control; keyed access not required
#pragma config WDTCCS = SC // WDT input clock selector->Software Control
// CONFIG4
#pragma config BBSIZE = BB512 // ->512 words boot block size
#pragma config BBEN = OFF // ->Boot Block disabled
#pragma config SAFEN = OFF // ->SAF disabled
#pragma config WRTAPP = OFF // ->Applic
#pragma congig WRTB = OFF
#pragma config WRTC = OFF
#pragma config WRTSAF = OFF
#pragma config LVP = ON
//CONFIG5
#pragma config CP = OFF
#define _XTAL_FREQ 8000000
#define LED1_DIR TRISAbits.TRISA4
#define LED1 LATAbits.LATA4
#define LED2_DIR TRISBbits.TRISB6
#define LED2 LATBbits.LATB6
void initIO(void)
{
LED1_DIR = 0;
LED2_DIR = 0;
ANSELA = 0x00;
ANSELB = 0x00;
}
void main(void)
{
initIO();
LED1 = 1;
LED2 = 1;
while(1)
{
LED1 = 1;
LED2 = 1;
__delay_ms(500);
LED1 = 0;
LED2 = 0;
__delay_ms(500);
}
return;
}
|