Other Parts Discussed in Thread: CC2640
Hello,
My goal is to set up a Timer, which reacts to an edge on the CC2640's Timerpin (DIO23 for Timer0). It should return the counter value, on which the edge was registered, so that the time between two events can be calculated.
Therefore I studied several forum articles, but I was unable to find a fitting one. Also the official TI documentation only provides an example explaining the periodic mode, but gives no hints on the other modes.
If anybody could provide an decent example or documentation I would be massively thankful.
Here you can see the code I am currently working on, which compiles without mistakes but does not return the counter value:
/* For usleep() */ #include <unistd.h> #include <stdint.h> #include <stddef.h> /* Driver Header files */ #include <ti/drivers/GPIO.h> #include <ti/drivers/Timer.h> #include <ti/drivers/timer/GPTimerCC26XX.h> #include <ti/drivers/pin/PINCC26XX.h> /* Board Header file */ #include "Board.h" /* Callback Function Prototyp */ void timerCallback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask); /* Variablen */ GPTimerCC26XX_Handle hTimer; uint32_t tVal_event = 0; /* Callback Function */ void timerCallback(GPTimerCC26XX_Handle handle, GPTimerCC26XX_IntMask interruptMask) { GPIO_write(Board_GPIO_LED1, Board_GPIO_LED_ON); } /* * ======== mainThread ======== */ void *mainThread(void *arg0) { GPTimerCC26XX_Params params; GPTimerCC26XX_Params_init(¶ms); params.width = GPT_CONFIG_16BIT; params.mode = GPT_MODE_EDGE_TIME_UP; params.debugStallMode = GPTimerCC26XX_DEBUG_STALL_OFF; hTimer = GPTimerCC26XX_open(Board_GPTIMER0A, ¶ms); GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_CAPTURE); GPTimerCC26XX_setLoadValue(hTimer, 0xFFFF); GPTimerCC26XX_setCaptureEdge(hTimer, GPTimerCC26XX_BOTH_EDGES); GPTimerCC26XX_start(hTimer); while(1){ tVal_event = GPTimerCC26XX_getValue(hTimer); } }
Kind Regards