#include "DSP28_Device.h"
Uint16 temp;
void CAP4init()
{
EvbRegs.GPTCONB.all=0x0000;
EvbRegs.CAP4FBOT=0x0000;
EvbRegs.CAP4FIFO=0x0000;
EvbRegs.CAPFIFOB.all=0x0000;
EvbRegs.T3CON.bit.TENABLE = 0;//暂时禁止T3计数
EvbRegs.T3CON.bit.TPS = 0; // 对外部信号不分频
EvbRegs.T3CON.bit.TMODE = 2; // 连续模式
EvbRegs.T3CON.bit.TCLKS10=0; //选择内部时钟
EvbRegs.T3PR=0xffff;
EvbRegs.T3CNT=0x0000;
//EvaRegs.CAPCON.all=0x0210; //捕获单元2为检测上升沿,选择Timer1为时钟
//EvaRegs.T1CON.all = 0xf74c; //Timer1 为连续增,预分频系数为128
EvbRegs.CAPCONB.bit.CAPRES=0; //捕获单元复位
EvbRegs.CAPCONB.bit.CAPQEPN=1; //使能捕获单元4和5
EvbRegs.CAPCONB.bit.CAP45TSEL=1; //选择通用定时器3
EvbRegs.CAPCONB.bit.CAP4EDGE=1; //CAP4检测上升沿
EvbRegs.EVBIMRC.bit.CAP4INT=1; //使能CAP4中断
EvbRegs.EVBIFRC.bit.CAP4INT=1; //清除CAP4中断标志位
}
void IOinit()
{
EALLOW;
GpioMuxRegs.GPBMUX.bit.CAP4Q1_GPIOB8 =1; //使能 CAP4 引脚
GpioMuxRegs.GPAMUX.bit.PWM5_GPIOA4=0; //设置PWM5引脚
GpioMuxRegs.GPAMUX.bit.PWM6_GPIOA5=0; //设置PWM6引脚
EDIS;
}
main(void)
{
InitSysCtrl(); //系统初始化
DINT; //禁止和清除所有CPU中断
IER = 0x0000;
IFR = 0x0000;
IOinit();
CAP4init();
InitPieCtrl();
InitPieVectTable();
PieVectTable.CAPINT4 =&CAPINT4_ISR;
PieCtrlRegs.PIEIER5.bit.INTx5=1; //使能PIE中断,CAP4中断位于INT5.5
IER|=M_INT5; //开CPU中断
EINT; //开全局中断
ERTM; //开实时中断
EvbRegs.T3CON.bit.TENABLE=1; //使能定时器T3计数操
while (1)
{
}
} |