这里在附上初始化程序希望工程师能看看是否有问题
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_4);
//使能外设
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinConfigure(GPIO_PB2_T3CCP0);
GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_2,GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_2);
//给定时器分频
TimerPrescaleSet(TIMER3_BASE, TIMER_A, 80);
//
//设置定时器为捕获定时
TimerConfigure(TIMER3_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME));
//设置为双边沿触发
TimerControlEvent(TIMER3_BASE, TIMER_A, TIMER_EVENT_BOTH_EDGES);
TimerIntEnable(TIMER3_BASE, TIMER_CAPA_EVENT);
//
IntEnable(INT_TIMER3A); //使能定时器中断
IntMasterEnable();
ROM_TimerLoadSet(TIMER3_BASE, TIMER_A, 0xffff);
TimerEnable(TIMER3_BASE, TIMER_A);//使能定时器
这里在附上初始化程序希望工程师能看看是否有问题
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_4);
//使能外设
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinConfigure(GPIO_PB2_T3CCP0);
GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_2,GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_2);
//给定时器分频
TimerPrescaleSet(TIMER3_BASE, TIMER_A, 80);
//
//设置定时器为捕获定时
TimerConfigure(TIMER3_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME));
//设置为双边沿触发
TimerControlEvent(TIMER3_BASE, TIMER_A, TIMER_EVENT_BOTH_EDGES);
TimerIntEnable(TIMER3_BASE, TIMER_CAPA_EVENT);
//
IntEnable(INT_TIMER3A); //使能定时器中断
IntMasterEnable();
ROM_TimerLoadSet(TIMER3_BASE, TIMER_A, 0xffff);
TimerEnable(TIMER3_BASE, TIMER_A);//使能定时器
举报