PICC 莫名的变量消失..

2020-02-10 08:33发布

我是个PIC初学者,今天写了个简单的程序,建了3个变量,但观察变量,发现并没有建立,如下程序
#include <pic.h>
#define uchar unsigned char                                               

__CONFIG (HS & PROTECT & PWRTEN & BOREN & WDTDIS);

void main(void)
{
    uchar i=1,j=2,k=3;
    i++;
    j++;
    k++;
    while(1);
}
并且在单步仿真的时候,指针是直接到while(1);的,为何?
但如果我把k++;改为k=i+j;,那么i和j就能建立了。
还有,首次编译的时候,会出现Warning [111] F:PICCPRO9.65includepic.h; 286.20 redefining preprocessor macro "EEADRL",这是什么?
请各位指点一下。谢谢
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
8条回答
yiminglei
1楼-- · 2020-02-10 10:14
再续
#include <pic.h>
#define uchar unsigned char

__CONFIG (HS & PROTECT & PWRTEN & BOREN & WDTDIS);

void main(void)
{
    uchar i,j=0;
    for(i=10;i!=0;i--)
    {
        j++;
    }
    while(1);
}
如程序,程序无办法进入for语句。。。为何?谢谢帮忙!
yiminglei
2楼-- · 2020-02-10 11:35
如果在uchar i,j=0;前加volatile,那问题就解决了。

PICC的优化能力太厉害了吧,怎么把它减低?
millwood0
3楼-- · 2020-02-10 17:09
"为何? "

you only need to think about it and you will get the answer.

"怎么把它减低?"

read the manual.
tiger1125
4楼-- · 2020-02-10 18:51
对于你第一个程序,我用的编译器的编译信息如下,不过我的PICC 9.65是没有激活的,只能用于Lite模式,不能对代码进行优化。

Build E:PIC_projectsc_test est for device 16F877A
Using driver D:Program FilesHI-TECH SoftwarePICCPRO9.65inpicc.exe

Make: The target "E:PIC_projectsc_test est.p1" is out of date.
Executing: "D:Program FilesHI-TECH SoftwarePICCPRO9.65inpicc.exe" --pass1 E:PIC_projectsc_test est.c -q --chip=16F877A -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error   [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Executing: "D:Program FilesHI-TECH SoftwarePICCPRO9.65inpicc.exe" -otest.cof -mtest.map --summary=default --output=default test.p1 --chip=16F877A -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error   [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
HI-TECH C PRO for the PIC10/12/16 MCU family (Lite)  V9.65PL1
Copyright (C) 1984-2009 HI-TECH SOFTWARE
(1273) Omniscient Code Generation not available in Lite mode (warning)

Memory Summary:
    Program space        used    1Ah (    26) of  2000h words   (  0.3%)
    Data space           used     4h (     4) of   170h bytes   (  1.1%)
    EEPROM space         used     0h (     0) of   100h bytes   (  0.0%)
    Configuration bits   used     1h (     1) of     1h word    (100.0%)
    ID Location space    used     0h (     0) of     4h bytes   (  0.0%)

Running this compiler in PRO mode, with Omniscient Code Generation enabled,
produces code which is typically 52% smaller than in Lite mode.
The HI-TECH C PRO compiler output for this code could be 13 words smaller.
See http://microchip.htsoft.com/portal/pic_pro for more information.

Loaded E:PIC_projectsc_test est.cof.

********** Build successful! **********


并没有你所说的警告信息。
而且可以创建变量……见下图:


(原文件名:picc.jpg)
usingavr
5楼-- · 2020-02-10 23:04
 精彩回答 2  元偷偷看……
qyb23
6楼-- · 2020-02-11 02:28

(原文件名:Snap1.jpg)

一周热门 更多>