为什么我把这个程序放到s12hz64里,却进不去中断呢?当然声明部分我是做了修改的
程序如下:
#include <hidef.h> /* common defines and macros */
#include <MC9S12HZ64.h> /* derivative information */
//#pragma LINK_INFO DERIVATIVE "MC9S12HZ64"
int intcount = 0;
void timer_init(void)
{
TSCR2_PR0 = 1; //prescale factor is 128
TSCR2_PR1 = 1;
TSCR2_PR2 = 1;
TSCR2_TOI = 1; //overflow enable
TFLG2_TOF = 1;
TSCR1_TEN = 1; //timer enable
}
#pragma CODE_SEG NON_BANKED
interrupt 16 void timer_interrupt_handle(void)
{
intcount++;
TFLG2_TOF = 1; //clear interrupt flag
};
#pragma CODE_SEG DEFAULT
void main(void)
{
EnableInterrupts;
timer_init();
for(;;) {}
}
dg128b的程序如下,这个可以仿真,看到intcount在不断增加
程序如下
#include <hidef.h> /* common defines and macros */
#include <mc9s12dg128.h> /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dg128b"
int intcount = 0;
void timer_init(void)
{
TSCR2_PR0 = 1; //prescale factor is 128
TSCR2_PR1 = 1;
TSCR2_PR2 = 1;
TSCR2_TOI = 1; //overflow enable
TFLG2_TOF = 1;
TSCR1_TEN = 1; //timer enable
}
#pragma CODE_SEG NON_BANKED
interrupt 16 void timer_interrupt_handle(void)
{
intcount++;
TFLG2_TOF = 1; //clear interrupt flag
};
#pragma CODE_SEG DEFAULT
void main(void)
{
EnableInterrupts;
timer_init();
for(;;) {}
}
上边这个是hz64的,下边这个是dg128的,应该是一致的
#define Vtimpaie 0x0000FFDA
#define Vtimpaovf 0x0000FFDC
#define Vtimovf 0x0000FFDE
#define Vtimch7 0x0000FFE0
#define Vtimch6 0x0000FFE2
#define Vtimch5 0x0000FFE4
#define Vtimch4 0x0000FFE6
#define Vtimch3 0x0000FFE8
#define Vtimch2 0x0000FFEA
#define Vtimch1 0x0000FFEC
#define Vtimch0 0x0000FFEE
#define Vrti 0x0000FFF0
#define VReserved6 0x0000FFF2
#define Vxirq 0x0000FFF4
#define Vswi 0x0000FFF6
#define Vtrap 0x0000FFF8
#define Vcop 0x0000FFFA
#define Vclkmon 0x0000FFFC
#define Vreset 0x0000FFFE
#define Vtimpaie 0x0000FFDA
#define Vtimpaaovf 0x0000FFDC
#define Vtimovf 0x0000FFDE
#define Vtimch7 0x0000FFE0
#define Vtimch6 0x0000FFE2
#define Vtimch5 0x0000FFE4
#define Vtimch4 0x0000FFE6
#define Vtimch3 0x0000FFE8
#define Vtimch2 0x0000FFEA
#define Vtimch1 0x0000FFEC
#define Vtimch0 0x0000FFEE
#define Vrti 0x0000FFF0
#define Virq 0x0000FFF2
#define Vxirq 0x0000FFF4
#define Vswi 0x0000FFF6
#define Vtrap 0x0000FFF8
#define Vcop 0x0000FFFA
#define Vclkmon 0x0000FFFC
#define Vreset 0x0000FFFE
这个应该在哪里看呢?不好意思,刚接触,问题问得比较没水平。
我把dg128下可以运行的例子,和在hz下不能进入中断的一起发上来,请帮忙看看吧
谢谢了
[attach]5825[/attach][此贴子已经被作者于2008-12-11 9:53:22编辑过]
因为我选的芯片是hz64的,上边的这个中断如果能运行,我要运行lvi的中断。
我觉得定时器的这个应该比较简单,如果这个都不能运行,那运行lvi中断恐怕就无从谈起了。还有,不知道版主对lvi中断了解多不多,我下边这么用行不行?
lvi中断如下所示
#include <hidef.h> /* common defines and macros */
#include <MC9S12HZ64.h> /* derivative information */
/*use the LVI interrupt to watch the power supply voltage and store
important data to EEPROM memory if the low voltage is detected. The time
is critical here - the data are supposed to be programmed prior to the
low voltage reset. So, that's not possible if the voltage falls down too
quickly.
In the other words:
If the supply voltage is below the specs (below 4.5V) then the ATD
accuracy and the functionality of input/output pins is affected. The MCU
is still working fine and also we can erase/program the EEPROM or FLASH
memory. The MCU is reset if the voltage is too low - if the supply
voltage is below VLVRA threshold (low voltage reset - assert level)
which is min 2.25V (you can find the specifications - in Appendix A).
Here is simple example how to use LVI interrupt: */
#pragma CODE_SEG NON_BANKED
interrupt 57 void LVI_ISR(void)
{
if(VREGCTRL_LVDS == 1)
{
//the voltage is bellow VLVIA threshold
//store the data to EEPROM here
}
else
{
//the voltage is above VLVID threshold
//do something here if needed
}
VREGCTRL_LVIF = 1; //clear the interrupt flag
}
#pragma CODE_SEG dEFAULT
void main(void)
{
VREGCTRL_LVIE = 1; //enable low voltage interrupt
EnableInterrupts;
//do something here
for(;;){ }
}
[此贴子已经被作者于2008-12-11 9:59:43编辑过]
建议你不要用中断号的方式定义中断矢量,最好用中断地址的方式,这样不容易出错。可以在PRM文件中这样定义:
VECTOR ADDRESS 0xFFDE timer_interrupt_handle
建议你不要用中断号的方式定义中断矢量,最好用中断地址的方式,这样不容易出错。可以在PRM文件中这样定义:
VECTOR ADDRESS 0xFFDE timer_interrupt_handle
这是软件的缺陷么?还是有什么别的需要注意的地方呢?
建议你不要用中断号的方式定义中断矢量,最好用中断地址的方式,这样不容易出错。可以在PRM文件中这样定义:
VECTOR ADDRESS 0xFFDE timer_interrupt_handle
按照这种定义改了,还是不行啊。我觉得这个问题很奇怪,不是软件哪里设置有问题吧
版主抽空看看我的源程序吧,都在附件里。
谢谢了
建议你不要用中断号的方式定义中断矢量,最好用中断地址的方式,这样不容易出错。可以在PRM文件中这样定义:
VECTOR ADDRESS 0xFFDE timer_interrupt_handle
按照这种定义改了,还是不行啊。我觉得这个问题很奇怪,不是软件哪里设置有问题吧
版主抽空看看我的源程序吧,都在附件里。
谢谢了
看来只有版主会上来回复问题啊
呵呵
用的是Full Chip Simulation,可以执行的,就是进不去中断
还有在dg128里的那个程序就可以的,我今天用hz64重新生成了一个工程,还是照旧不能进中断
改成4.7版本就可以了,真是很奇怪
时不时hz64的芯片不如dg128的常用,而软件本身也存在bug?
可能版本越高,bug也会越少吧
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |