Part Number: LAUNCHXL-CC1352R1
while (1)
{
// Check if capture is generated
if(interrupt_flag > 0){
if(interrupt_flag == 1){
captureTime_1 = GPTimerCC26XX_getValue(timerHandle); // first capture
}
if(interrupt_flag == 2){
captureTime_2 = GPTimerCC26XX_getValue(timerHandle); // second capture
timeDifference = (65535*overflow + captureTime_2) - captureTime1; // take time difference
printf("Time Difference: %d\n", timeDifference); // debug
// Reset global variables
interrupt_flag = 0;
overflow = 0;
}
GPTimerCC26xx_start(timerHandle); // start timer
}
}
void timerCallback(GPTimerCC26XX_Handle timerHandle, int_fast16_t status){
overflow++; // update overflow
}
void gpioInterruptHandler(uint_least8_t index){
interrupt_flag++; // update interrupt_flag
GPTimerCC26xx_stop(timerHandle); // stop timer
}
Here is the code implementation for input capture by accessing the current value of the timer using the built-in library, GPTimerCC26xx.h. The usual configuration is used for GPIO using the GPIO.h library. Unfortunately, this implementation provides inaccurate captures leading to erroneous time difference. Is there a limitation to the header function used?
Thank you!
Thank you!