Thread 中讨论的其他器件: EK-TM4C123GXL
以下是我在输入边沿时间模式中配置 tm4c123gh下午6的 timer0的代码。 我使用 EK-tm4c123gxl 的板载开关触发事件。 检测到事件、但当我按下按钮时。 但我无法 使用 TimerValueGet () API 读取计时器的当前值。 是否有任何其他可返回计时器当前值的 API。
#include
#include
#include" driverlib/sysctl.h"
#include" driverlib/gpio.h"
#include"driverlib/interrupt.h"
#include" driverlib/timer.h"
#include" driverlib/pin_map.h"
#include "inc/tm4c123gh6pm .h"
#include "inc/hw_memmap.h"
uint32_t a=0、b;
int main (void){
SysCtlClockSet (SYSCTL_XTAL_16MHz|SYSCTL_OSC_MAIN|SYSCTL_USE_PLL|SYSCTL_SYSDIV_5);
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOB);
GPIOPinTypeTimer (GPIO_PORTB_BASE、GPIO_PIN_6);
GPIOPinConfigure (GPIO_PB6_T0CCP0);
SysCtlPeripheralEnable (SYSCTL_Periph_GPIOF);
GPIOPinTypeGPIOInput (GPIO_PORTF_BASE、GPIO_PIN_4);
GPIOPadConfigSet (GPIO_PORTF_BASE、GPIO_PIN_4、GPIO_Strength _4mA、GPIO_PIN_TYPE_STD_WPU);
SysCtlPeripheralEnable (SYSCTL_Periph_TIMER0);
TimerConfigure (TIMER0_BASE、TIMER_CFG_SPLIT_PAGE|TIMER_CFG_A_CAP_TIME_UP);
TimerLoadSet (TIMER0_BASE、TIMER_A、65000);
TimerControlEvent (TIMER0_BASE、TIMER_A、TIMER_EVENT_POS_EDGE);
IntEnable (INT_TIMER0A);
TimerIntEnable (TIMER0_BASE、TIMER_CAP_EVENT);
TimerEnable (TIMER0_BASE、TIMER_A);
while (1){
B=TimerValueGet (TIMER0_BASE、TIMER_A);
SysCtlDelay (100);
}
}
空 timer0_ISR (空)
{
A++;
TimerIntClear (TIMER0_BASE、TIMER_CAP_EVENT);
}