GPTimerCC26XX_Handle hTimer; void timerCallback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) {// interrupt callback code goes here. Minimize processing in interrupt. } void taskFxn(uintptr_t a0, uintptr_t a1) {GPTimerCC26XX_Params params;GPTimerCC26XX_Params_init(¶ms);params.width= GPT_CONFIG_16BIT;params.mode= GPT_MODE_PERIODIC;params.direction= GPTimerCC26XX_DIRECTION_UP;params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;hTimer = GPTimerCC26XX_open(CC2650_GPTIMER0A, ¶ms);if(hTimer == NULL) {Log_error0("Failed to open GPTimer");Task_exit();}Types_FreqHz freq;BIOS_getCpuFreq(&freq);GPTimerCC26XX_Value loadVal = freq.lo / 1000 - 1; //47999GPTimerCC26XX_setLoadValue(hTimer, loadVal);GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_TIMEOUT);GPTimerCC26XX_start(hTimer);while(1) {Task_sleep(BIOS_WAIT_FOREVER);} }
如果我将TIMER的工作模式改成了GPT_MODE_EDGE_COUNT ,并用GPTimerCC26XX_getValue来获取一段时间内我捕获的边缘数目。那在上面的范例代码中,周期计时模式是在定时时间到达后调用回调函数 timerCallback的,但是如果是EDGE_COUNT模式呢?回调函数是在什么时候调用?是在定时时间结束吗?
如果是定时时间结束后调用?我是不是可以在回调函数中使用GPTimerCC26XX_getValue来获取该时间段内捕获的边缘数目?
Kevin Qiu1:
你说的GPT_MODE_EDGE_COUNT和EDGE_COUNT不是同一个模式吗,是在定时时间结束后调用
user6359397:
回复 Kevin Qiu1:
是一样的,我在代码实现的时候他一直在等待边缘事件的发生,但我并不知道它到底在检测哪个引脚的事件,比如说我想用DIO21来检测脉冲数量,要怎么配置我的输入端口?
user6359397:
回复 Kevin Qiu1:
GPTimerCC26XX_Handle hTimer; GPTimerCC26XX_Value timer_Value; static PIN_State TimerPins; static PIN_Handle TimerPinHandle = NULL;PIN_Config TimerinitTable[] = {PIN_TIMER | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_BOTHEDGES |PIN_HYSTERESIS,PIN_TERMINATE };void timerCallback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) {// interrupt callback code goes here. Minimize processing in interrupt.timer_Value = GPTimerCC26XX_getValue(hTimer);Log_info0("timer_working!");Log_info1("Value is %d",timer_Value);} extern void timer_init(void) {if(TimerPinHandle==NULL){TimerPinHandle = PIN_open(&TimerPins,TimerinitTable);}PINCC26XX_setMux(TimerPinHandle, PIN_TIMER, GPT_PIN_0A );GPTimerCC26XX_Params params;GPTimerCC26XX_Params_init(¶ms);params.width= GPT_CONFIG_16BIT;params.mode= GPT_MODE_EDGE_COUNT;params.direction= GPTimerCC26XX_DIRECTION_UP;params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;hTimer = GPTimerCC26XX_open(Board_GPTIMER0A, ¶ms);if(hTimer == NULL) {Log_error0("Failed to open GPTimer");Task_exit();}xdc_runtime_Types_FreqHzfreq;BIOS_getCpuFreq(&freq);GPTimerCC26XX_Value loadVal = freq.lo / 100 - 1;GPTimerCC26XX_setLoadValue(hTimer, loadVal);GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_CAPTURE);GPTimerCC26XX_setCaptureEdge(hTimer,GPTimerCC26XX_BOTH_EDGES);GPTimerCC26XX_start(hTimer);}我按照历程写了边缘捕获的代码,但并没有成功调用回调函数,这是什么环节出现问题呢?
Kevin Qiu1:
回复 user6359397:
你用的是哪个例程?
user6359397:
回复 Kevin Qiu1:
file:///home/magic/ti/simplelink_cc2640r2_sdk_4_10_00_10/docs/tidrivers/doxygen/html/_g_p_timer_c_c26_x_x_8h.html#ab4a2e82c659e0ea1fa2ae7a852298359a46af9b3278d2116fd4862c7fe19624b7
Kevin Qiu1:
回复 user6359397:
这部分代码的功能只是利用定时器产生中断,参考下这里:e2e.ti.com/…/433597
Kevin Qiu1:
回复 Kevin Qiu1:
设置引脚用PINCC26XX_setMux()
PIN_Status PINCC26XX_setMux ( PIN_Handle handle,PIN_Id pinId,int32_t nMux )
Connect pin to HW peripheral, signal or to GPIO.
Parameters
handle
Handle provided by previous call to PIN_open()pinId
Pin IDnMux
Device-specific index of peripheral port or hardware signal. A value of -1 reverts the pin to GPIO mappingReturnsPIN_SUCCESS if successful, else error codeNoteMostly used by driver code or for diagnosticsUsage
PIN_setMux(hPins, PIN_ID(16), PINCC26XX_UART_TX);
user6359397:
回复 Kevin Qiu1:
/*!*@brief*Definitions for supported GPTimer interrupts. GPTimerCC26XX_IntMask*arguments should be a bit vector containing these definitions.*See description in Technical Reference*/ typedef enum GPTimerCC26XX_Interrupt {GPT_INT_TIMEOUT= 1 << 0,GPT_INT_CAPTURE_MATCH = 1 << 1,GPT_INT_CAPTURE= 1 << 2,GPT_INT_MATCH= 1 << 3, } GPTimerCC26XX_Interrupt;GPT_INT_CAPTURE_MATCH = 1 << 1,GPT_INT_CAPTURE= 1 << 2,GPT_INT_MATCH= 1 << 3,这三种模式都是如何触发中断的??为什么我选择GPT_INT_CAPTURE就不会触发中断,但使用GPT_INT_CAPTURE_MATCH就可以没有看到这三个触发条件的详细描述阿,能解释下吗