首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

版主帮忙看下我的cop错误

版主帮忙看下我的cop错误

我写了一个小程序试验cop


#define _ENABLE_COP(period)   ((*(volatile unsigned char*)_COPCTL_ADR)= (period)) /* Note: 7 longest posible COP duration. 0 == COP disabled. */
#define _ENABLE_COP_X() _ENABLE_COP(7) /* as long as possible */
#define _DISABLE_COP() _ENABLE_COP(0x00) /* COP is disabled if period is 0 */
#define _FEED_COP()   ((*(volatile unsigned char*)_COP_RST_ADR)= 0x55,(*(volatile unsigned char*)_COP_RST_ADR)= 0xAA)


#include <hidef.h>      /* common defines and macros */
#include <MC9S12NE64.h>     /* derivative information */
#include "MOTTYPES.h"



#pragma LINK_INFO DERIVATIVE "MC9S12NE64"


tU16 count;
void main(void) {


    CRGINT_RTIE = 0;                     /* Disable interrupt */
    RTICTL_RTR = 0x73;                   /* Store given value to the prescaler */
    CRGFLG = CRGINT_RTIE_MASK;           /* Reset interrupt request flag */
    CRGINT_RTIE = 1;                     /* Enable interrupt */
 
  _ENABLE_COP(1);
 
  /* put your own code here */
  EnableInterrupts;
  for(;;) {} /* wait forever */
}


 


#pragma CODE_SEG NON_BANKED
void interrupt 7 RTI(void)
{
  CRGFLG = CRGINT_RTIE_MASK;           /* Reset interrupt request flag */
  count++;
  _FEED_COP(); 
}
#pragma CODE_SEG DEFAULT


 


程序运行一段时间 就会报错,请问这可能是怎么回事?

正在进行NE64的研究学习,欢迎和我讨论~ saga0807@hotmail.com
COP应该在主程序里清。在中断里清WATCHDOG能保证间隔吗?即使能,也是不好的。因为有可能主程序跑飞后,中断还能发生,这样WATCHDOG就其不到作用了。
海纳百川  有容乃大
可是我现在把喂狗操作放在for循环里,程序还是会跑飞,而且调试器不能进入断点和停止,只能复位。

正在进行NE64的研究学习,欢迎和我讨论~ saga0807@hotmail.com

还有我想问下版主,我想通过cop使mcu复位。那我的cop复位中断向量处是不是应该写_Startup?

还有怎么停止喂狗? 

[此贴子已经被作者于2006-7-11 9:51:46编辑过]

正在进行NE64的研究学习,欢迎和我讨论~ saga0807@hotmail.com
COP复位发生后,整个MCU就复位了,不管COP中断向量处写的是不是_Startup。至于COP中断向量处到底要写什么,就要看发生COP复位后你的程序要怎么处理了。

怎么停止喂狗?我想,你的程序应该根据某个控制标志来判断是否要继续喂狗。
海纳百川  有容乃大
tU16 count;
void main(void) {

_ENABLE_COP(1);

/* put your own code here */
EnableInterrupts;
for(;;) {
count++;
_FEED_COP();
if (count==1000) goto NOT_FEED;
} /* wait forever */

NOT_FEED:for(;;){}
}

我这样试了一下,停止喂狗后程序还是跳转到ffff,请问该怎么调试

[此贴子已经被作者于2006-7-11 10:29:56编辑过]

正在进行NE64的研究学习,欢迎和我讨论~ saga0807@hotmail.com
你的COP中断矢量里写的是什么地址?
海纳百川  有容乃大
我试过在prm文件里写VECTOR 2 _Startup
也试过写一个空的中断函数
#pragma CODE_SEG NON_BANKED
void interrupt 2 COP(void){}

#pragma CODE_SEG DEFAULT
但是都这样
正在进行NE64的研究学习,欢迎和我讨论~ saga0807@hotmail.com
把你的整个project打包发给我看看吧:strongchen_free@yahoo.com.cn
海纳百川  有容乃大
谢谢版主,程序我已经发过去了
正在进行NE64的研究学习,欢迎和我讨论~ saga0807@hotmail.com
你可以这样试试:
void main(void) {

INITRM=0;
count=0;

_ENABLE_COP(1);

/* put your own code here */
EnableInterrupts;
for(;;) {
count++;
_FEED_COP();
if (count==1000) goto NOT_FEED;
} /* wait forever */

NOT_FEED:for(;;){}
}
海纳百川  有容乃大
这样还是不行,我又写了这样一个vector文件
#pragma CODE_SEG __NEAR_SEG NON_BANKED /* Interrupt section for this module. Placement will be in NON_BANKED area. */

__interrupt void Cpu_Interrupt(void)
{
}


__interrupt void Cpu_Interrupt1(void)
{
}
#pragma CODE_SEG DEFAULT /* Change code section to DEFAULT. */



typedef void (*near tIsrFunc)(void);
const tIsrFunc _vect[] @0xFF80 = { /* Interrupt table */
Cpu_Interrupt, /* 0 Default (unused) interrupt */
Cpu_Interrupt, /* 1 Default (unused) interrupt */
Cpu_Interrupt, /* 2 Default (unused) interrupt */
Cpu_Interrupt, /* 3 Default (unused) interrupt */
Cpu_Interrupt, /* 4 Default (unused) interrupt */
Cpu_Interrupt, /* 5 Default (unused) interrupt */
Cpu_Interrupt, /* 6 Default (unused) interrupt */
Cpu_Interrupt, /* 7 Default (unused) interrupt */
Cpu_Interrupt, /* 8 Default (unused) interrupt */
Cpu_Interrupt, /* 9 Default (unused) interrupt */
Cpu_Interrupt, /* 10 Default (unused) interrupt */
Cpu_Interrupt, /* 11 Default (unused) interrupt */
Cpu_Interrupt, /* 12 Default (unused) interrupt */
Cpu_Interrupt, /* 13 Default (unused) interrupt */
Cpu_Interrupt, /* 14 Default (unused) interrupt */
Cpu_Interrupt, /* 15 Default (unused) interrupt */
Cpu_Interrupt, /* 16 Default (unused) interrupt */
Cpu_Interrupt, /* 17 Default (unused) interrupt */
Cpu_Interrupt, /* 18 Default (unused) interrupt */
Cpu_Interrupt, /* 19 Default (unused) interrupt */
Cpu_Interrupt, /* 20 Default (unused) interrupt */
Cpu_Interrupt, /* 21 Default (unused) interrupt */
Cpu_Interrupt, /* 22 Default (unused) interrupt */
Cpu_Interrupt, /* 23 Default (unused) interrupt */
Cpu_Interrupt, /* 24 Default (unused) interrupt */
Cpu_Interrupt, /* 25 Default (unused) interrupt */
Cpu_Interrupt, /* 26 Default (unused) interrupt */
Cpu_Interrupt, /* 27 Default (unused) interrupt */
Cpu_Interrupt, /* 28 Default (unused) interrupt */
Cpu_Interrupt, /* 29 Default (unused) interrupt */
Cpu_Interrupt, /* 30 Default (unused) interrupt */
Cpu_Interrupt, /* 31 Default (unused) interrupt */
Cpu_Interrupt, /* 32 Default (unused) interrupt */
Cpu_Interrupt, /* 33 Default (unused) interrupt */
Cpu_Interrupt, /* 34 Default (unused) interrupt */
Cpu_Interrupt, /* 35 Default (unused) interrupt */
Cpu_Interrupt, /* 36 Default (unused) interrupt */
Cpu_Interrupt, /* 37 Default (unused) interrupt */
Cpu_Interrupt, /* 38 Default (unused) interrupt */
Cpu_Interrupt, /* 39 Default (unused) interrupt */
Cpu_Interrupt, /* 40 Default (unused) interrupt */
Cpu_Interrupt, /* 41 Default (unused) interrupt */
Cpu_Interrupt, /* 42 Default (unused) interrupt */
Cpu_Interrupt, /* 43 Default (unused) interrupt */
Cpu_Interrupt, /* 44 Default (unused) interrupt */
Cpu_Interrupt, /* 45 Default (unused) interrupt */
Cpu_Interrupt, /* 46 Default (unused) interrupt */
Cpu_Interrupt, /* 47 Default (unused) interrupt */
Cpu_Interrupt, /* 48 Default (unused) interrupt */
Cpu_Interrupt, /* 49 Default (unused) interrupt */
Cpu_Interrupt, /* 50 Default (unused) interrupt */
Cpu_Interrupt, /* 51 Default (unused) interrupt */
Cpu_Interrupt, /* 52 Default (unused) interrupt */
Cpu_Interrupt, /* 53 Default (unused) interrupt */
Cpu_Interrupt, /* 54 Default (unused) interrupt */
Cpu_Interrupt, /* 55 Default (unused) interrupt */
Cpu_Interrupt, /* 56 Default (unused) interrupt */
Cpu_Interrupt, /* 57 Default (unused) interrupt */
Cpu_Interrupt, /* 58 Default (unused) interrupt */
Cpu_Interrupt, /* 59 Default (unused) interrupt */
Cpu_Interrupt, /* 60 Default (unused) interrupt */
Cpu_Interrupt1, /* 61 Default (unused) interrupt */
Cpu_Interrupt, /* 62 Default (unused) interrupt */
_Startup /* Reset vector */
};

但是不管我把 Cpu_Interrupt1 放在那个中断向量处,调试器都回出现上面图中的情况,并且代码停在
__interrupt void Cpu_Interrupt1(void)
{
}
中断函数处
正在进行NE64的研究学习,欢迎和我讨论~ saga0807@hotmail.com
还有如果不开启cop,或者一直正常喂狗都不会发生这种情况
正在进行NE64的研究学习,欢迎和我讨论~ saga0807@hotmail.com
你是在用硬件进行调试吗?出现这种情况应该是正常的吧,因为芯片发生了复位,BDM的通讯就断掉了。你的问题到底是什么?
海纳百川  有容乃大
是硬件调试。BDM通信断掉了?我是看到调试器报错,就是ILLEGAL_BP,然后调试器SOURCE就停在上面那个中断处,是因为BDM通信断掉了?那就是说我的程序是没有问题的?
正在进行NE64的研究学习,欢迎和我讨论~ saga0807@hotmail.com
返回列表