各位前辈,本菜鸟刚上手学习PIC单片机,用的是 PIC16F877A,工具是MPLAB X IDE v5.45 配合 xc8-v2.30、和MCC4.1.0。
手头上有个例程,是用MPLAB IDE和PICC写的,我想用X IDE移植,现在编译成功、烧写都成功了,但是无法点亮LED。用例程的hex文件可以点亮LED,但是我移植的就不行。怀疑是晶振设置问题,但是各种配置都试过了,还是不行。各位前辈有什么经验吗?这个第一步我想只要跨过去了,后续应该就好办了。
如能赐教,感激不尽!
代码如下:
#pragma config FOSC = EXTRC // Oscillator Selection bits (RC oscillator)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR disabled)
#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming)
#pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off)
#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control)
#pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off)
#include <xc.h>
void main(void)
{
TRISD=0x00;
PORTD=0x01;
while(1)//
{
PORTD=0x01;
}
}
|