打印

很奇怪的PICC编译问题

[复制链接]
5118|9
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
544852010|  楼主 | 2012-9-6 14:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Mplab软件和PICC编译器,PIC12F509单片机,程序如下

#include<htc.h>
//#include "main.h"
__CONFIG(MCLRDIS&WDTDIS&UNPROTECT&INTRC);     //设置配置位(MCLR脚复位禁止,看门狗关,无代码保护,内部RC振荡)

void DelayUS(unsigned char delay)
{
//while(--delay);
NOP();NOP();NOP();NOP();NOP();
}
void main()
{
while(1)
{
  DelayUS(100);
}
}
#ifndef     __MAIN_H__
#define     __MAIN_H__
#endif
很奇怪的问题,main函数中去掉延时函数,就正常了,只要有一处调用延时函数,就增加200%,10处调用延时函数,就2000%,目前还不知道怎么解决此问题。
另外,烧写进去的程序,20%的程序正常,其余均出现数据混乱程序运行时间不对,但是程序流程还是对的。
另外,同样的Mpalb和PICC编译器,打开别的工程,程序调用延时函数,一切正常,未出现这种提示。

程序编译后:
Clean: Deleting intermediary and output files.
Clean: Deleted file "E:\PIC_12F508\main.obj".
Clean: Deleted file "E:\PIC_12F508\main.cce".
Clean: Deleted file "PIC_12F508.cof".
Clean: Done.
Executing: "D:\Project_soft\Mplab\setup\PICC950\bin\picc.exe" -C -E"main.cce" "main.c" -O"main.obj" -Zg9 -O -ASMLIST -Q -MPLAB -12F509
Advisory[1209]   : An old MPLAB tool suite plug-in was detected. Some options may not work correctly
Advisory[1210]   : Visit www.htsoft.com or contact support@htsoft.com for an update
Executing: "D:\Project_soft\Mplab\setup\PICC950\bin\picc.exe" -E"PIC_12F508.lde" "E:\PIC_12F508\main.obj" -M"PIC_12F508.map" -O"PIC_12F508.cof" -O"PIC_12F508.hex" -Q -MPLAB -12F509
Memory Usage Map:
Program space:
    CODE                 used     Fh (    15) of   400h words   (  1.5%)
    ENTRY                used    15h (    21) of   400h words   (  2.1%)
Data space:
    BANK0                used     4h (     4) of    19h bytes   ( 16.0%)
    BANK1                used     0h (     0) of    10h bytes   (  0.0%)
    COMBANK              used     0h (     0) of    10h bytes   (  0.0%)
EEPROM space:
                         None available
ID Location space:
    IDLOC                used     0h (     0) of     4h bytes   (  0.0%)
Configuration bits:
    CONFIG               used     1h (     1) of     1h word    (100.0%)
Extra space:
    STRING               used     2h (     2) of     1h unit    (200.0%)

Summary:
    Program space        used    24h (    36) of   400h words   (  3.5%)
    Data space           used     4h (     4) of    30h bytes   (  8.3%)
    EEPROM space         None available
    ID Location space    used     0h (     0) of     4h bytes   (  0.0%)
    Configuration bits   used     1h (     1) of     1h word    (100.0%)
                         used     2h (     2) of     1h unit    (200.0%)

Advisory[1209]   : An old MPLAB tool suite plug-in was detected. Some options may not work correctly
Advisory[1210]   : Visit www.htsoft.com or contact support@htsoft.com for an update
Loaded E:\PIC_12F508\PIC_12F508.cof.
BUILD SUCCEEDED: Thu Sep 06 14:07:18 2012
沙发
544852010|  楼主 | 2012-9-6 14:11 | 只看该作者
main函数如下写法,就不会出现上面红色字体部分提示

#include<htc.h>
#include "main.h"

__CONFIG(MCLRDIS&WDTDIS&UNPROTECT&INTRC);     //设置配置位(MCLR脚复位禁止,看门狗关,无代码保护,内部RC振荡)


void DelayUS(unsigned char delay)
{
        //while(--delay);
        NOP();NOP();NOP();NOP();NOP();
}

void main()
{
        while(1)
        {
                ;
        }
}

编译后如下:
Clean: Deleting intermediary and output files.
Clean: Deleted file "E:\PIC_12F508\main.obj".
Clean: Deleted file "E:\PIC_12F508\main.cce".
Clean: Deleted file "PIC_12F508.cof".
Clean: Done.
Executing: "D:\Project_soft\Mplab\setup\PICC950\bin\picc.exe" -C -E"main.cce" "main.c" -O"main.obj" -Zg9 -O -ASMLIST -Q -MPLAB -12F509
Advisory[1209]   : An old MPLAB tool suite plug-in was detected. Some options may not work correctly
Advisory[1210]   : Visit www.htsoft.com or contact support@htsoft.com for an update
Executing: "D:\Project_soft\Mplab\setup\PICC950\bin\picc.exe" -E"PIC_12F508.lde" "E:\PIC_12F508\main.obj" -M"PIC_12F508.map" -O"PIC_12F508.cof" -O"PIC_12F508.hex" -Q -MPLAB -12F509

Memory Usage Map:

Program space:
    CODE                 used     Bh (    11) of   400h words   (  1.1%)
    ENTRY                used    15h (    21) of   400h words   (  2.1%)

Data space:
    BANK0                used     4h (     4) of    19h bytes   ( 16.0%)
    BANK1                used     0h (     0) of    10h bytes   (  0.0%)
    COMBANK              used     0h (     0) of    10h bytes   (  0.0%)

EEPROM space:
                         None available

ID Location space:
    IDLOC                used     0h (     0) of     4h bytes   (  0.0%)

Configuration bits:
    CONFIG               used     1h (     1) of     1h word    (100.0%)


Summary:
    Program space        used    20h (    32) of   400h words   (  3.1%)
    Data space           used     4h (     4) of    30h bytes   (  8.3%)
    EEPROM space         None available
    ID Location space    used     0h (     0) of     4h bytes   (  0.0%)
    Configuration bits   used     1h (     1) of     1h word    (100.0%)


Advisory[1209]   : An old MPLAB tool suite plug-in was detected. Some options may not work correctly
Advisory[1210]   : Visit www.htsoft.com or contact support@htsoft.com for an update
Loaded E:\PIC_12F508\PIC_12F508.cof.
BUILD SUCCEEDED: Thu Sep 06 14:09:47 2012

使用特权

评论回复
板凳
544852010|  楼主 | 2012-9-7 08:27 | 只看该作者
已经搞定,谢谢,是PICC编译器**问题,用自带**补丁的PICC960版本编译器就搞定了,谢谢大家!

使用特权

评论回复
地板
544852010|  楼主 | 2012-9-7 08:31 | 只看该作者
麻烦来个朋友,帮忙回复下,方便我结贴给分,20分,自己回复的,给不了自己分,谢谢

使用特权

评论回复
5
yimankehao| | 2012-9-7 09:03 | 只看该作者
你的延时函数的变量delay没有起到作用,调用后一直是执行5个NOP();

使用特权

评论回复
6
yewuyi| | 2012-9-7 09:21 | 只看该作者
在MPLAB中都已经不这样写了:#include <htc.h>

一般都直接:#include <PIC.h>

while(--delay);已经被你屏蔽了,所以 DelayUS(100);中的100也就没意义了。

使用特权

评论回复
7
linqing171| | 2012-9-7 12:59 | 只看该作者
用XC8,有试用版本。或者其他公司的编译器。htc,效率最差。

使用特权

评论回复
8
yewuyi| | 2012-9-8 09:08 | 只看该作者
用XC8,有试用版本。或者其他公司的编译器。htc,效率最差。
linqing171 发表于 2012-9-7 12:59


XC8也是HITECH公司出的,是MICROCHIP收购HITECH后开发出来的PIC16专用编译器,但其实和原来的PICC也不会相差太大。
PICC PRO版本效率还可以的。

使用特权

评论回复
9
544852010|  楼主 | 2012-9-28 14:44 | 只看该作者
谢谢大家!

使用特权

评论回复
10
xueweianying| | 2012-9-28 15:46 | 只看该作者
楼主在湖北人啊!

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:LED行业应用技术支持工程师,欢迎多多交流!QQ-544852

35

主题

68

帖子

1

粉丝