找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4367|回复: 4
收起左侧

MPLAB X IDE的编译器HI更换为XC8后程序烧录后没反应(编译通过)用HI可以

[复制链接]
ID:307950 发表于 2020-7-17 19:29 | 显示全部楼层 |阅读模式
5黑币
大家好,我最近用MPLAB X IDE,开始我用这个键工程,选择的编译器是HI的,程序烧录进去运行OK的,然后我吧编译器更改为XC8,配置也用IDE 生成的,其余代码一模一样,编译OK,但下载后就没反应,不知道是怎么回事,希望有好心人帮忙解决下,谢谢。以下是代码:有前面有两句中文注释是更改编译器后要改的,后面的代码是一模一样的,应该需要怀疑什么。
/*
* File:   main.c
* Author: 时间
*
* Created on 2020年6月26日, 下午6:57
*/


// PIC12F675 Configuration Bit Settings

// 'C' source line config statements

// CONFIG

//#pragma config MCLRE = OFF

//以下9句是XC8编译器使用的
#include <xc.h> //
#pragma config FOSC = HS     // Oscillator Selection bits (RC oscillator)
#pragma config WDTE = OFF        // Watchdog Timer Enable bit (WDT enabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
#pragma config BOREN = ON       // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = ON         // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3/PGM pin has PGM function; low-voltage programming enabled)
#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)

//以下两局是用HI编译器使用的
//#include<pic.h>                      //包含单片机内部资源预定义
//__CONFIG(0xFF32);      //PIC16F877A 配置位



//__CONFIG(0x03F2;0X3FFF); //16F887 配置位

void delay();
/****************************************************************************
* 名    称:main()
* 功    能:主函数
* 入口参数:
* 出口参数:
* 说    明:
****************************************************************************/
void main()                 
{
        TRISD = 0x00;                          //portd 输出
        PORTC = 0x00;     //74HC138控制端口
      
        while (1)         //死循环,让数码管持续点亮
        {
                PORTD=0b00000001; //点亮第1个发光管
                delay();
                PORTD=0b00000000; //关掉发光管 也可以写成16位的 自己试一试吧
                delay();
               
                PORTD=0b00000010; //点亮第2个发光管
                delay();
                PORTD=0b00000000; //关掉发光管 也可以写成16位的 自己试一试吧
                delay();
               
                PORTD=0b00000100; //点亮第3个发光管
                delay();
                PORTD=0b00000000; //关掉发光管 也可以写成16位的 自己试一试吧
                delay();
               
                PORTD=0b00001000; //点亮第4个发光管
                delay();
                PORTD=0b00000000; //关掉发光管 也可以写成16位的 自己试一试吧
                delay();
                              
                PORTD=0b00010000; //点亮第5个发光管
                delay();
                PORTD=0b00000000; //关掉发光管 也可以写成16位的 自己试一试吧
                delay();
               
                PORTD=0b00100000; //点亮第6个发光管
                delay();
                PORTD=0b00000000; //关掉发光管 也可以写成16位的 自己试一试吧
                delay();
               
                PORTD=0b01000000; //点亮第7个发光管
                delay();
                PORTD=0b00000000; //关掉发光管 也可以写成16位的 自己试一试吧
                delay();
               
                PORTD=0b10000000; //点亮第8个发光管
                delay();
                PORTD=0b00000000; //关掉发光管 也可以写成16位的 自己试一试吧
                delay();


                PORTD=0b11111111; //点亮全部发光管
                delay();
                PORTD=0b00000000; //关掉发光管 也可以写成16位的 自己试一试吧
                delay();
                        PORTD=0b11111111; //点亮全部发光管
                delay();
                PORTD=0b00000000; //关掉发光管 也可以写成16位的 自己试一试吧
                delay();
                        PORTD=0b11111111; //点亮全部发光管
                delay();
                PORTD=0b00000000; //关掉发光管 也可以写成16位的 自己试一试吧
                delay();
                        PORTD=0b11111111; //点亮全部发光管
                delay();
                PORTD=0b00000000; //关掉发光管 也可以写成16位的 自己试一试吧
                delay();
        }
}
/****************************************************************************
* 名    称:delay()   
* 功    能:延时
* 入口参数:
* 出口参数:
* 说    明:
****************************************************************************/
void delay()              
{
        int i;                 //定义整形变量
        for (i = 65000;i--;);     //延时
     {
       ;
       ;
       ;

     }
}

回复

使用道具 举报

ID:595237 发表于 2020-7-18 01:25 | 显示全部楼层
是不是xc8 没有破解吧
回复

使用道具 举报

ID:307950 发表于 2020-7-18 19:47 | 显示全部楼层
juncedz 发表于 2020-7-18 01:25
是不是xc8 没有破解吧

破解过了,这是编译结果清除已成功 (总时间: 2s)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'G:/TEST/TEST.X'
make  -f nbproject/Makefile-default.mk dist/default/production/TEST.X.production.hex
make[2]: Entering directory 'G:/TEST/TEST.X'
"C:\Program Files (x86)\Microchip\xc8\v1.45\bin\xc8.exe" --pass1  --chip=16F877A -Q -G  --double=24 --float=24 --opt=+asm,+asmfile,+speed,-space,-debug,-local --addrqual=ignore --mode=pro -P -N255 --strict --warn=-3 --asmlist -DXPRJ_default=default  --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,+oscval:0x3400,-resetbits,-download,-stackcall,+clib   --output=+mcof,-elf:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s"    -obuild/default/production/main.p1  main.c
:: warning: (913) "--strict" option can cause compiler errors in some standard header files
"C:\Program Files (x86)\Microchip\xc8\v1.45\bin\xc8.exe"  --chip=16F877A -G -mdist/default/production/TEST.X.production.map  --double=24 --float=24 --opt=+asm,+asmfile,+speed,-space,-debug,-local --addrqual=ignore --mode=pro -P -N255 --strict --warn=-3 --asmlist -DXPRJ_default=default  --summary=default,-psect,-class,+mem,-hex,-file --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+osccal,+oscval:0x3400,-resetbits,-download,-stackcall,+clib --output=+mcof,-elf:multilocs --stack=compiled:auto:auto "--errformat=%f:%l: error: (%n) %s" "--warnformat=%f:%l: warning: (%n) %s" "--msgformat=%f:%l: advisory: (%n) %s"      --memorysummary dist/default/production/memoryfile.xml -odist/default/production/TEST.X.production.cof  build/default/production/main.p1     
Microchip MPLAB XC8 C Compiler (PRO Mode) V1.41
Build date: Jan 24 2017
Part Support Version: 1.45
Copyright (C) 2017 Microchip Technology Inc.
:: warning: (913) "--strict" option can cause compiler errors in some standard header files
main.c:66: warning: (751) arithmetic overflow in constant expression
main.c:63: warning: (520) function "_delay" is never called

Memory Summary:
    Program space        used     Dh (    13) of  2000h words   (  0.2%)
    Data space           used     2h (     2) of   170h bytes   (  0.5%)
    EEPROM space         used     0h (     0) of   100h bytes   (  0.0%)
    Data stack space     used     0h (     0) of    60h bytes   (  0.0%)
    Configuration bits   used     1h (     1) of     1h word    (100.0%)
    ID Location space    used     0h (     0) of     4h bytes   (  0.0%)

make[2]: Leaving directory 'G:/TEST/TEST.X'
make[1]: Leaving directory 'G:/TEST/TEST.X'

编译已成功 (总时间: 10s)
正在加载代码G:/TEST/TEST.X/dist/default/production/TEST.X.production.hex...
加载完成
回复

使用道具 举报

ID:1079270 发表于 2024-5-11 15:49 | 显示全部楼层
可以分享一下xc8是怎么安装成功的吗,我安装好了可以索引到,可以就是编译不成功
回复

使用道具 举报

ID:1019848 发表于 2024-8-21 11:18 | 显示全部楼层
我觉得0b00000001的二进制文件需要一个头文件定义
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表