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

CC1310 nortos time demo

CC1310 NORTOS的 有定时器使用demo例程吗

Viki Shi:

可以参考PWM例程,里面用到了timer,有nortos版:dev.ti.com/…/node

user6497810:

要怎么设置才可以让定时器一直重复跑?

user6497810:

回复 user6497810:

    GPTimerCC26XX_Params params;    params.width          = GPT_CONFIG_32BIT;    params.mode           = GPT_MODE_ONESHOT_UP;    params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF;    hTimer = GPTimerCC26XX_open(Board_GPTIMER0A, &params);    if(hTimer == NULL)    {        while(1);    }     rxTimeoutVal = (SysCtrlClockGet()*3UL)/10UL – 1UL;    GPTimerCC26XX_setLoadValue(hTimer, rxTimeoutVal);    GPTimerCC26XX_registerInterrupt(hTimer, rxTimeoutCb, GPT_INT_TIMEOUT); GPTimerCC26XX_start(hTimer);

void rxTimeoutCb(GPTimerCC26XX_Handle handle,                 GPTimerCC26XX_IntMask interruptMask){    GPTimerCC26XX_setLoadValue(hTimer, rxTimeoutVal); PIN_setOutputValue(pinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));  //GPTimerCC26XX_start(hTimer);}

请问要怎么样设置才能使定时器重复进入中断?

必须要在回调函数里面每次去 start吗?

Viki Shi:

回复 user6497810:

你要用GPTimer的什么模式?下面是我配置的下降沿中断检测的代码,每次检测到下降沿,就打印感叹号:

/***** 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);}
}

user6497810:

回复 Viki Shi:

我用的是GPT_INT_TIMEOUT

Viki Shi:

回复 user6497810:

好的,例程里是单次计数,多次计数需要改为周期性计数模式

赞(0)
未经允许不得转载:TI中文支持网 » CC1310 nortos time demo
分享到: 更多 (0)