打印

调试运行时间偏长

[复制链接]
551|23
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
houcs|  楼主 | 2020-3-1 10:00 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
KIT3调试运行时间偏长
以5s延时为例,调试运行需要大概15s时间,烧录运行只需1.5s左右,
也就是说运行的指令时间有问题

使用特权

评论回复
沙发
llia| | 2020-3-1 10:06 | 只看该作者
程序

使用特权

评论回复
板凳
houcs|  楼主 | 2020-3-1 10:08 | 只看该作者

#include<xc.h>
// CONFIG1
#pragma config FOSC = XT        // Oscillator Selection (XT Oscillator, Crystal/resonator connected between OSC1 and OSC2 pins)
#pragma config WDTE = SWDTEN     // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable (PWRT disabled)
#pragma config MCLRE =  ON         // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)
#pragma config CP = OFF         // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config CPD = OFF        // Data Memory Code Protection (Data memory code protection is disabled)
#pragma config BOREN =   OFF      // Brown-out Reset Enable (Brown-out Reset enabled)
#pragma config CLKOUTEN = OFF   // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
#pragma config IESO = ON        // Internal/External Switchover (Internal/External Switchover mode is enabled)
#pragma config FCMEN = ON       // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled)
// CONFIG2
#pragma config WRT = OFF        // Flash Memory Self-Write Protection (Write protection off)
#pragma config VCAPEN = OFF     // Voltage Regulator Capacitor Enable bit (Vcap functionality is disabled on RA6.)
#pragma config PLLEN = ON       // PLL Enable (4x PLL enabled)
#pragma config STVREN = ON      // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
#pragma config BORV = LO        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config LPBOR = OFF      // Low Power Brown-Out Reset Enable Bit (Low power brown-out is disabled)
#pragma config LVP =  OFF         // Low-Voltage Programming Enable (Low-voltage programming enabled)

void delayms(unsigned int x)    //延时 x ms
{
    unsigned int i,j;
    for(i=x;i>0;i--)
        for(j=110;j>0;j--);
}

void main()
{
        TRISD=0x00;
while(1)
{
         LATD=0X00;
        delayms(5000);
        LATD=0XFF;
        delayms(5000);
}
}

使用特权

评论回复
地板
wenfen| | 2020-3-1 10:11 | 只看该作者
先不要怀疑KIT3,通常都是代码中有鬼

使用特权

评论回复
5
wangpe| | 2020-3-1 10:14 | 只看该作者
应该是配置字的问题

使用特权

评论回复
6
houcs|  楼主 | 2020-3-1 10:18 | 只看该作者
我认为是配置字的问题,器件我也更换了,结果相同

使用特权

评论回复
7
zhanglli| | 2020-3-1 10:21 | 只看该作者
你这种delay时间很难精准的,不过Debug和Release为什么会差别这么大,确实很奇怪,

使用特权

评论回复
8
yinxiangh| | 2020-3-1 10:23 | 只看该作者
你可以考虑用Timer做delay

使用特权

评论回复
9
ousj| | 2020-3-1 10:29 | 只看该作者
你的watchdog enable了,但是没有看到喂狗。所以我怀疑贴出的代码段,应该是截取出来的代码。

使用特权

评论回复
10
xxmmi| | 2020-3-1 10:36 | 只看该作者
你代码中有中断吗,中断会影响你的通过指令来delay的时长。

使用特权

评论回复
11
llia| | 2020-3-1 10:51 | 只看该作者
你的程序Release模式有没有使用优化,如果有的话,可以试试关掉优化,重新编译烧写,再看效果如何

使用特权

评论回复
12
houcs|  楼主 | 2020-3-1 11:03 | 只看该作者
看门狗配置位设置为01(即SWDTEN模式),这是看门狗使能由WDTCONbits.SWDTEN控制。

使用特权

评论回复
13
huwr| | 2020-3-1 11:09 | 只看该作者
打开了吗

使用特权

评论回复
14
houcs|  楼主 | 2020-3-1 11:13 | 只看该作者
本程序阶段我并未打开此位(并暂停查看过次位为0,即为禁止)

使用特权

评论回复
15
wangpe| | 2020-3-1 11:16 | 只看该作者
用定时器timer0做过延时吗

使用特权

评论回复
16
houcs|  楼主 | 2020-3-1 11:19 | 只看该作者
嗯,同样的情况,也就是不是延时函数的问题,而是程序运行指令的时间并不是4M晶振下1us的时间,这是我不懂的!!!

使用特权

评论回复
17
wangzsa| | 2020-3-1 11:24 | 只看该作者

使用特权

评论回复
18
happy_10| | 2020-3-1 11:25 | 只看该作者
有没有现成的驱动安装,支持PRO-06的呢?

使用特权

评论回复
19
wangpe| | 2020-3-1 11:30 | 只看该作者

使用特权

评论回复
20
wangzsa| | 2020-3-1 11:34 | 只看该作者
晶振4M, 但是4xPLL 后Fsys就是16M了,

使用特权

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

本版积分规则

743

主题

8382

帖子

5

粉丝