我在用定时器做外部输入边缘计数功能时,计数不正常,比如我用定时器来计数按键按下次数,按键按下是低电平,需要按键保持低电平1s以上才能计数一次,按键电平示波器看过,一按下就变低,松开就变高,具体初始化代码如下:
#define Radio_PIN IOID_19
PIN_Config RadioPinTable[] =
{
Radio_PIN | PIN_GPIO_OUTPUT_DIS | PIN_INPUT_EN | PIN_PULLUP,
PIN_TERMINATE
};
RadioPinHandle = PIN_open(&RadioPinState, RadioPinTable);
//RTOS: Enable peripheral domain and clocks for timer
Power_setDependency(PERIPH_GPT1);
PINCC26XX_setMux(RadioPinHandle, Radio_PIN, IOC_PORT_MCU_PORT_EVENT2);
//TimerDisable(GPT1_BASE,TIMER_BOTH);
TimerConfigure(GPT1_BASE,TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_CAP_COUNT);
TimerEventControl(GPT1_BASE,TIMER_A,TIMER_EVENT_NEG_EDGE);
//TimerPrescaleSet(GPT1_BASE,TIMER_A,0);
TimerLoadSet(GPT1_BASE,TIMER_A,65535);
TimerMatchSet(GPT1_BASE,TIMER_A,1);
//TimerIntRegister(GPT1_BASE,TIMER_A,Radio_callback);
//TimerIntEnable(GPT1_BASE,TIMER_CAPA_MATCH);
TimerEnable(GPT1_BASE,TIMER_A);
我用的是定时器1A,配置的引脚是IOID_19,希望帮忙分析下代码上有没有问题。 或者有做过的可以给一些参考,谢谢! |