打印

无法进入中断问题

[复制链接]
220|13
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
liuzaiy|  楼主 | 2019-6-23 17:24 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

TIMR8  的中断

也查了一下以前的资料,情况是

1.timr81_int.asm 中添加了 ljmp _Timer8_1_ISR_C
仍然不行

使用特权

评论回复
沙发
yinxiangh| | 2019-6-23 17:30 | 只看该作者
源代码呢

使用特权

评论回复
板凳
liuzaiy|  楼主 | 2019-6-23 17:33 | 只看该作者

#pragma interrupt_handler Timer8_1_ISR_C
void Timer8_1_ISR_C(void)
{
     static BYTE ucCnt = 0;
     ucCnt++;
     if(ucCnt == 100){
            ucCnt = 0;
             PRT1DR ^=  BIT_MASK6;

    }
//return;
}

void main(void)
{

  M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts
   Timer8_1_WritePeriod(10);//vc3 = vc1/16/5/100    T unit = 1ms   
  Timer8_WriteCompareValue(0x00);
   Timer8_1_EnableInt();
   Timer8_1_Start();
   
// Insert your main routine code here.
while(1){
   
}

使用特权

评论回复
地板
chenjunt| | 2019-6-23 17:36 | 只看该作者
你怎么配置的

使用特权

评论回复
5
liuzaiy|  楼主 | 2019-6-23 17:40 | 只看该作者


_Timer8_1_ISR:

   ;@PSoC_UserCode_BODY@ (Do not change this line.)
    ;---------------------------------------------------
    ; Insert your custom assembly code below this banner
    ;---------------------------------------------------
    ;   NOTE: interrupt service routines must preserve
    ;   the values of the A and X CPU registers.
   
    ;---------------------------------------------------
    ; Insert your custom assembly code above this banner
    ;---------------------------------------------------
    ljmp _Timer8_1_ISR_C
    //_Timer8_1_ISR_C
    ;---------------------------------------------------
    ; Insert a lcall to a C function below this banner
    ; and un-comment the lines between these banners
    ;---------------------------------------------------
   
    pRESERVE_CPU_CONTEXT
    ;lcall _My_C_Function
    ;RESTORE_CPU_CONTEXT
   
    ;---------------------------------------------------
    ; Insert a lcall to a C function above this banner
    ; and un-comment the lines between these banners
    ;---------------------------------------------------
    ;@PSoC_UserCode_END@ (Do not change this line.)

   reti

使用特权

评论回复
6
pangb| | 2019-6-23 17:43 | 只看该作者


static BYTE ucCnt = 0; 这一句应该定义成全局变量。

使用特权

评论回复
7
zyf部长| | 2019-6-23 17:50 | 只看该作者
嗯,你这里每次进入中断时都对 ucCnt 重新定义并赋值 0, 这样 ucCnt 只能在 0 和 1 之间变化,不会到达 100.

使用特权

评论回复
8
xxmmi| | 2019-6-23 17:54 | 只看该作者

改成这样试一下:
#include <m8c.h>        // part specific constants and macros
#include "PSoCAPI.h"    // PSoC API definitions for all User Modules

static BYTE ucCnt;

#pragma interrupt_handler Timer8_1_ISR_C
void Timer8_1_ISR_C(void)
{
         ucCnt++;
     if(ucCnt == 100)
         {
         ucCnt = 0;
         PRT1DR ^= 0x40;
     }
}

void main(void)
{

        M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts
         Timer8_1_WritePeriod(10);//vc3 = vc1/16/5/100    T unit = 1ms   
         Timer8_1_WriteCompareValue(0x00);
         Timer8_1_EnableInt();
         Timer8_1_Start();
         
        while(1)
         {
                 ;
         }
   
}

使用特权

评论回复
9
liuzaiy|  楼主 | 2019-6-23 18:00 | 只看该作者
问题找到 是Timer8_1_WritePeriod(10);下面那条语句写成了Timer8_1_WritePeriod(0);

使用特权

评论回复
10
liuzaiy|  楼主 | 2019-6-23 18:03 | 只看该作者
另外模块中断类型要选对  T Count 溢出类型

使用特权

评论回复
11
kangzj| | 2019-6-29 22:23 | 只看该作者

static 变量的作用就是函数内局部变量保存

使用特权

评论回复
12
zwll| | 2019-6-29 22:32 | 只看该作者
这个根本不需要定义成全局变量

使用特权

评论回复
13
juventus9554| | 2019-6-29 22:39 | 只看该作者
真不是每次都定义赋值的,定义赋值只有一次,这种写法完全没问题,同志

使用特权

评论回复
14
liuzaiy|  楼主 | 2019-6-29 22:44 | 只看该作者
嗯,我再好好缕一缕吧,有了好消息及时通知大家,结贴喽

使用特权

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

本版积分规则

735

主题

7546

帖子

2

粉丝