TI中文支持网
TI专业的中文技术问题搜集分享网站

CC2640R2F GPTimer的使用

您好,参考例程,请问hTimer = GPTimerCC26XX_open(CC2650_GPTIMER0A, &params)中,CC2650_GPTIMER0A是什么?取值范围为0-7吗?我填了一个7,提示Error[Li005]: no definition for "GPTimerCC26XX_config" [referenced from GPTimerCC26XX.orm3(drivers_cc26x0r2.arm3)]

Viki Shi:

/*!*@briefGPTimer26XX Hardware attributes**These fields are used by the driver to set up underlying GPTimer*driver statically. A sample structure is shown below:**@code*// GPTimer hardware attributes, one per timer unit (Timer 0A, 0B, 1A, 1B..)*const GPTimerCC26XX_HWAttrs gptimerCC26xxHWAttrs[CC2650_GPTIMERPARTSCOUNT] = {*{.baseAddr = GPT0_BASE, .intNum = INT_TIMER0A, .powerMngrId = PERIPH_GPT0, .pinMux = GPT_PIN_0A, },*{.baseAddr = GPT0_BASE, .intNum = INT_TIMER0B, .powerMngrId = PERIPH_GPT0, .pinMux = GPT_PIN_0B, },*{.baseAddr = GPT1_BASE, .intNum = INT_TIMER1A, .powerMngrId = PERIPH_GPT1, .pinMux = GPT_PIN_1A, },*{.baseAddr = GPT1_BASE, .intNum = INT_TIMER1B, .powerMngrId = PERIPH_GPT1, .pinMux = GPT_PIN_1B, },*{.baseAddr = GPT2_BASE, .intNum = INT_TIMER2A, .powerMngrId = PERIPH_GPT2, .pinMux = GPT_PIN_2A, },*{.baseAddr = GPT2_BASE, .intNum = INT_TIMER2B, .powerMngrId = PERIPH_GPT2, .pinMux = GPT_PIN_2B, },*{.baseAddr = GPT3_BASE, .intNum = INT_TIMER3A, .powerMngrId = PERIPH_GPT3, .pinMux = GPT_PIN_3A, },*{.baseAddr = GPT3_BASE, .intNum = INT_TIMER3B, .powerMngrId = PERIPH_GPT3, .pinMux = GPT_PIN_3B, },*};*@endcode*/

梦与远方:

回复 Viki Shi:

那我第一个参数应该传入什么呢?按例程传入CC2650_GPTIMER0A,会报错

Viki Shi:

回复 梦与远方:

CC2640R2F上使用应该是CC2640R2_LAUNCHXL_GPTIMER0A

梦与远方:

回复 Viki Shi:

CC2640R2_LAUNCHXL_GPTIMER0A提示我未定义,请问这个是包含在哪个头文件?

Viki Shi:

回复 梦与远方:

CC2640R2_LAUNCHXL.h,timer的使用建议参考PWMLED2这个例程

梦与远方:

回复 Viki Shi:

使用边沿计时器的话要参考哪个例程呢?

梦与远方:

回复 Viki Shi:

我添加了CC2640R2_LAUNCHXL.h,提示我no definition for "GPTimerCC26XX_config" [referenced from GPTimerCC26XX.orm3(drivers_cc26x0r2.arm3)],GPTimerCC26XX_config是在哪个文件里定义的?

Viki Shi:

回复 梦与远方:

GPTimerCC26XX.h

梦与远方:

回复 Viki Shi:

我要是想使用IOID27与timer0的引脚联系起来,要怎么配置呢?

Viki Shi:

回复 梦与远方:

通过PINCC26XX_setMux();函数

这是我之前一个下降沿检测的例子,供参考:

/***** Includes *****/
/* Standard C Libraries */
#include <stdlib.h>
#include <stdio.h>/* RTOS header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>/* TI Drivers */
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>
#include <ti/drivers/pin/PINCC26XX.h>
#include <ti/drivers/timer/GPTimerCC26XX.h>/* Driverlib Header files */
#include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)/* Board Header files */
#include "Board.h"/***** Variable declarations *****/
/* Pin driver handle */
static PIN_Handle ledPinHandle;
static PIN_State ledPinState;PIN_Config pinTable[] =
{IOID_0 | PIN_INPUT_EN | PIN_PULLUP | PIN_IRQ_NEGEDGE,PIN_TERMINATE
};GPTimerCC26XX_Handle hTimer0A;
//static uint8_t counter = 0;void timerCallback0A(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask)
{printf("!\n");
}/***** Function definitions *****/void *mainThread(void *arg0)
{/* Open LED pins */ledPinHandle = PIN_open(&ledPinState, pinTable);if (ledPinHandle == NULL){while(1);}GPTimerCC26XX_Params params0A;GPTimerCC26XX_Params_init(&params0A);params0A.width= GPT_CONFIG_16BIT;params0A.mode= GPT_MODE_EDGE_COUNT_UP;params0A.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;hTimer0A = GPTimerCC26XX_open(CC2640R2_LAUNCHXL_GPTIMER0A, &params0A);if(hTimer0A == NULL){while(1);}GPTimerCC26XX_registerInterrupt(hTimer0A, timerCallback0A, GPT_INT_CAPTURE_MATCH);GPTimerCC26XX_PinMux pinMux = GPTimerCC26XX_getPinMux(hTimer0A);PINCC26XX_setMux(ledPinHandle, IOID_0, pinMux);GPTimerCC26XX_setCaptureEdge(hTimer0A, GPTimerCC26XX_NEG_EDGE);GPTimerCC26XX_setLoadValue(hTimer0A, 0xFFFFFF);GPTimerCC26XX_setMatchValue(hTimer0A, 1);GPTimerCC26XX_start(hTimer0A);while(1){Task_sleep(BIOS_WAIT_FOREVER);}
}

赞(0)
未经允许不得转载:TI中文支持网 » CC2640R2F GPTimer的使用
分享到: 更多 (0)