我是PIC的新手。我正在将MPLAB IDE版本8.92与Pickit 2和XC8编译器一起使用。我试图对PIC12F508芯片进行编程以使LED闪烁。该程序已构建并编程到芯片中。但是LED不闪烁,所以我想到了调试程序。我选择无程序员,然后选择Pickit 2调试器。之后,单击“连接”,然后单击“程序”。错误提示我PK2Error0027: Failed verify (Address = 0x4 - Expected Value 0x64 - Value Read 0x60)
。如果单击“调试器”菜单下的“运行”,它将显示PK2Error0028: unable to enter debug mode
。我是否缺少某些东西或做错了什么?
更新程序:
#define _XTAL_FREQ 4000000
#include <xc.h>
//__CONFIG(MCLRE_ON & CP_OFF & WDT_OFF & OSC_IntRC);
#pragma config OSC = IntRC // Oscillator Selection bits (internal RC oscillator)
#pragma config WDT = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config CP = OFF // Code Protection bit (Code protection off)
#pragma config MCLRE = ON // GP3/MCLR Pin Function Select bit (GP3/MCLR pin function is digital input, MCLR internally tied to VDD)
void main()
{
TRIS = 0b011111;
GPIObits.GP5 = 1;
__delay_ms(1000);
GPIObits.GP5 = 0;
__delay_ms(1000);
}
包括:
答案 0 :(得分:1)
调试的问题是12F508不具有调试功能。您只能对此设备编程。许多较早的PIC单片机(尤其是8引脚器件)没有调试芯片。有时会有一个特殊的调试头,该调试头具有硅片的调试版本以及调试功能,并具有用于访问调试器的附加引脚。
有关此主题的更多信息,请查看这篇文章:https://www.microforum.cc/topic/16-debugging-low-pincount-picmicrocontrollers
答案 1 :(得分:0)
您需要第二次延迟:
include <xc.h>
#define _XTAL_FREQ 4000000
void main()
{
TRIS = 0b000000;
for (;;)
{
GPIO = 0b00111111; //work with 8 Bits here
__delay_ms(1000);
GPIO = 0b00000000;
__delay_ms(1000); //delay loop for OFF time
}
}
那是您的LED出现的错误。对于PICKit错误,请查看配置设置。与__CONFIG _DEBUG_OFF
一起尝试。