在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 2761|回复: 1

[原创] 中断与定时器问题,请各位高手给指点一下!

[复制链接]
发表于 2009-7-13 16:35:50 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
本帖最后由 cjsb37 于 2013-4-29 09:06 编辑

外部两个中断不同时发生,用定时器1来对这两个中断发生的时间进行计时,不知为什么每次计时两个中断发生的时间竟然是一样的,请各位前辈给指点一下!
下面是我的程序:
#include <csl.h>
#include <csl_emifa.h>
#include <csl_irq.h>
#include <csl_chip.h>
#include <csl_timer.h>
#include <csl_gpio.h>
#include <stdio.h>
#include "seeddm642.h"
#include "seeddm642_uart.h"


static TIMER_Handle hTimer1;

static Uint32 TimerEventId;

static unsigned int cnt = 0;
static unsigned int t1 = 0;
static unsigned int t2 = 0;
static unsigned int v = 0;
static Uint32 TimerControl =

            

    TIMER_CTL_RMK

    (

        TIMER_CTL_SPND_EMUSTOP,

          TIMER_CTL_INVINP_NO,         // TINP inverter control(INVINP)

          TIMER_CTL_CLKSRC_CPUOVR8,    // Timer input clock source (CLKSRC)

        TIMER_CTL_CP_PULSE,         // Clock/pulse mode(CP)

        TIMER_CTL_HLD_YES,             // Hold(HLD)

        TIMER_CTL_GO_NO,             // Go bit(GO)-

                                    //   resets & starts timer counter

        TIMER_CTL_PWID_ONE,         // Pulse width(PWID)-

                                    //   used only in pulse mode

        TIMER_CTL_DATOUT_0,         // Data output (DATOUT)

        TIMER_CTL_INVOUT_NO,         // TOUT inverter control (INVOUT)

        TIMER_CTL_FUNC_GPIO         // Function of TOUT pin(FUNC)

    );     


extern far void vectors();
static unsigned char flag ;
/*此程序可将四个采集口的数据经过Video Port0送出*/
void main()
{
    TIMER_Config myTimConfig;
    CSL_init();
    IRQ_setVecs(vectors);   
    hTimer1 = TIMER_open(TIMER_DEV1, 0);
    TimerEventId = TIMER_getEventId(hTimer1);
    GPIO_RSET(GPEN,0x1E0);//
    GPIO_RSET(GPDIR,0x100);/*将GPIO做为输出*/
    GPIO_RSET(GPVAL,0x000);
    IRQ_globalDisable();
    IRQ_nmiDisable();
    IRQ_nmiEnable();
    IRQ_globalEnable();
    IRQ_map(TimerEventId, 15);
    IRQ_map(IRQ_EVT_EXTINT6,6);
    IRQ_map(IRQ_EVT_EXTINT7,7);   
    IRQ_reset(TimerEventId);
    IRQ_reset(IRQ_EVT_EXTINT6);
    IRQ_reset(IRQ_EVT_EXTINT7);
    IRQ_RSET(EXTPOL,0x0E);//下降沿中断
     myTimConfig.cnt = 0x0;
    myTimConfig.ctl = TimerControl;
    myTimConfig.prd = 0x00124f8; //定时1ms
    IRQ_enable(TimerEventId);        
    IRQ_enable(IRQ_EVT_EXTINT6);
    IRQ_enable(IRQ_EVT_EXTINT7);
    TIMER_config(hTimer1, &myTimConfig);
   
     TIMER_start(hTimer1);
   
     while(1);               
}

interrupt void ext_isr6()
{
   
   t1 = 0.5+cnt*75000*8/600000;//75000对应myTimConfig.prd = 0x00124f8
      printf("t1 : %d\n",t1);
}     

interrupt void ext_isr7()
{
   t2 =0.5+ cnt*75000*8/600000;
   printf("t2 : %d\n",t2);
}

interrupt void CLK_cnt()
{
   cnt++;
}

以下是仿真结果:
t1 : 68//中断不同时发生t1,t2应该是不一样的啊,
t2 : 68//不知仿真结果为什么是一样的?
t1 : 165
t2 : 165
t1 : 348
t2 : 348
t1 : 531
t2 : 531
t1 : 713
t2 : 713
t1 : 893
t2 : 893
t1 : 1076
t2 : 1076
t1 : 1219
t2 : 1219





 楼主| 发表于 2009-7-15 10:51:42 | 显示全部楼层
难道是我的定时时间设置的不对吗?希望顶级开发网的顶级高手给指导一下!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /1 下一条

小黑屋| 手机版| 关于我们| 联系我们| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2025-2-2 04:43 , Processed in 0.015198 second(s), 8 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表