|
用WTIIME1写一个测频计(高频部分),低频用的是捕获计时模式可以测出结果,高频用捕获计数模式,但测试高频部分时TIMEA模块不进中断,TIMERB可以正常中断,这是什么原因?
void Init_WTIMER1_HighFre(void) //初始化
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER1);//启用Timer1模块模块
SysCtlDelay(1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);//启用GPIO作为脉冲捕捉引脚
SysCtlDelay(1);
ROM_GPIOPinConfigure(GPIO_PC6_WT1CCP0); //配置GPIO脚为捕捉模式
ROM_GPIOPinTypeTimer(GPIO_PORTC_BASE,GPIO_PIN_6);
ROM_GPIOPadConfigSet(GPIO_PORTC_BASE, GPIO_PIN_6,
GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
// 配置使用Timer4的TimerA模块为边沿触发减计数模式
ROM_TimerConfigure( WTIMER1_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_COUNT
|TIMER_CFG_B_PERIODIC);
ROM_TimerControlEvent( WTIMER1_BASE, TIMER_A, TIMER_EVENT_NEG_EDGE);
// ROM_TimerIntRegister(WTIMER1_BASE,TIMER_A,ISR_WTimer1A);
ROM_TimerLoadSet (WTIMER1_BASE, TIMER_A, 11000);
ROM_TimerLoadSet (WTIMER1_BASE, TIMER_B, 16000000);
ROM_TimerMatchSet(WTIMER1_BASE, TIMER_A, 10000);
ROM_IntMasterEnable ();
ROM_TimerIntEnable (WTIMER1_BASE,TIMER_TIMA_MATCH | TIMER_TIMB_TIMEOUT);
ROM_IntEnable (INT_WTIMER1A);
ROM_IntEnable (INT_WTIMER1B);
ROM_TimerEnable (WTIMER1_BASE, TIMER_A );
ROM_TimerEnable (WTIMER1_BASE, TIMER_B);
}
void ISR_WTimer1A(void)
{
uint32_t CapTimer_Fre;
uint32_t ulStatus;
uint8_t PinStatus;
ulStatus = TimerIntStatus(WTIMER1_BASE,false);
TimerIntClear (WTIMER1_BASE, ulStatus);
if(ulStatus & TIMER_CAPA_MATCH)
{
ROM_TimerControlEvent( WTIMER1_BASE, TIMER_A, TIMER_EVENT_NEG_EDGE);
ROM_TimerLoadSet(WTIMER1_BASE, TIMER_A, 11000);
ROM_TimerEnable(WTIMER1_BASE, TIMER_A);
CapTimer_Fre=TimerValueGet(WTIMER1_BASE, TIMER_B);
fre_temp_tick= CapTimer_Fre_Ori + (Fre_TimerOutCount*16000000) - CapTimer_Fre;
CapTimer_Fre_Ori = CapTimer_Fre;
Fre_Cur_Frequency=(uint64_t)1000*80000000 / fre_temp_tick;
Fre_TimerOutCount=0;
}
PinStatus = GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_1); // 反转LED
GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1, ~PinStatus);
}
void ISR_WTimer1B(void)
{
uint32_t ulStatus;
ulStatus = TimerIntStatus(WTIMER1_BASE,false);
TimerIntClear (WTIMER1_BASE, ulStatus); // 清除中断标志位
// TimerEnable (WTIMER1_BASE, TIMER_B);
Fre_TimerOutCount++;
if(GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_2))
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0);
}
else
{
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 4);
}
}
|
|