打印
[STM8]

stm8s003中断问题

[复制链接]
3728|6
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
mokaixing|  楼主 | 2014-7-10 17:14 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
stm8s003程序我用ST进行调试,stm8s_interrupt_vector.c是系统自动生成的,但是我调试的时候程序一直在这个里面出不来,求解释!新手不知道怎么发图片,这里直接贴文字了,这个就是在系统自动生成的stm8s_interrupt_vector.c中!
@far @interrupt void NonHandledInterrupt (void)
{
        /* in order to detect unexpected events during development,
           it is recommended to set a breakpoint on the following instruction
        */
        return;
}
沙发
mmuuss586| | 2014-7-10 17:34 | 只看该作者

使用特权

评论回复
板凳
jxmzzr| | 2014-7-10 22:17 | 只看该作者
这个应该是发生不正常的跳转了,检查下参数设置。

使用特权

评论回复
地板
拿起书本| | 2014-7-10 22:18 | 只看该作者
说明找不到你的定时器中断,你看一下定时器中断向量那有没有指定对应的中断函数。

使用特权

评论回复
5
huangfeng33| | 2014-7-10 22:20 | 只看该作者
中断函数设计的不对啊, 那就必须修改参数哦。

使用特权

评论回复
6
hopewise| | 2014-7-11 08:13 | 只看该作者
先要在stm8s_interrupt_vector.c声明一下主程序所用到的中断函数(比如TIM4_IRQ ),然后修改struct interrupt_vector里的中断内容见下:

typedef void @far (*interrupt_handler_t)(void);

struct interrupt_vector {
        unsigned char interrupt_instruction;
        interrupt_handler_t interrupt_handler;
};

@far @interrupt void NonHandledInterrupt (void)
{
        /* in order to detect unexpected events during development,
           it is recommended to set a breakpoint on the following instruction
        */
        return;
}

extern void _stext();     /* startup routine */

extern @far @interrupt void EXTI_PORTA_IRQ (void);
extern @far @interrupt void TIM4_IRQ (void);

struct interrupt_vector const _vectab[] = {
        {0x82, (interrupt_handler_t)_stext}, /* reset */
        {0x82, NonHandledInterrupt}, /* trap  */
        {0x82, NonHandledInterrupt}, /* irq0  */
        {0x82, NonHandledInterrupt}, /* irq1  */
        {0x82, NonHandledInterrupt}, /* irq2  */
        {0x82, EXTI_PORTA_IRQ},      /* irq3  */   
        {0x82, NonHandledInterrupt}, /* irq4  */
        {0x82, NonHandledInterrupt}, /* irq5  */
        {0x82, NonHandledInterrupt}, /* irq6  */
        {0x82, NonHandledInterrupt}, /* irq7  */
        {0x82, NonHandledInterrupt}, /* irq8  */
        {0x82, NonHandledInterrupt}, /* irq9  */
        {0x82, NonHandledInterrupt}, /* irq10 */
        {0x82, NonHandledInterrupt}, /* irq11 */
        {0x82, NonHandledInterrupt}, /* irq12 */
        {0x82, NonHandledInterrupt}, /* irq13 */
        {0x82, NonHandledInterrupt}, /* irq14 */
        {0x82, NonHandledInterrupt}, /* irq15 */
        {0x82, NonHandledInterrupt}, /* irq16 */
        {0x82, NonHandledInterrupt}, /* irq17 */
        {0x82, NonHandledInterrupt}, /* irq18 */
        {0x82, NonHandledInterrupt}, /* irq19 */
        {0x82, NonHandledInterrupt}, /* irq20 */
        {0x82, NonHandledInterrupt}, /* irq21 */
        {0x82, NonHandledInterrupt}, /* irq22 */
        {0x82, TIM4_IRQ},            /* irq23 */
        {0x82, NonHandledInterrupt}, /* irq24 */
        {0x82, NonHandledInterrupt}, /* irq25 */
        {0x82, NonHandledInterrupt}, /* irq26 */
        {0x82, NonHandledInterrupt}, /* irq27 */
        {0x82, NonHandledInterrupt}, /* irq28 */
        {0x82, NonHandledInterrupt}, /* irq29 */
};
最后在主程序里写中断内容(中断名字要与stm8s_interrupt_vector.c里的所声明的中断名字相同,除了extern外).主程序里的中断如下(假如用到TIM4中断):
/************************************************
* 名称:     TIM4_IRQ        
* 功能:     TIM4中断服务子程序
* 入口参数: 无
* 出口参数: 无
* 说明:                                            
*************************************************/
@far @interrupt void TIM4_IRQ (void)
{
                  t_us ++;
                 TIM4_SR=0X00;      //清除更新标志UIF
           if(f_buzon)        //蜂鸣器翻转(f=2K)
           {
                      if(buz)  buz=0;
                      else     buz=1;
           }
           else buz=0;        //关蜂鸣器(低电平关)
}         

使用特权

评论回复
7
hopewise| | 2014-7-11 08:16 | 只看该作者
stm8s_interrupt_vector.c原先的{0x82, NonHandledInterrupt}, /* irq23 * 改为 / {0x82, TIM4_IRQ},            /* irq23 */
.

使用特权

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

本版积分规则

2

主题

4

帖子

1

粉丝