|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
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
|
|