Hi,
In <virtual_com.c> file, the APPTask() function, there call below function to calculate the time difference.
uint16_t timeDifference = TimersAndCo_GetTimeDifference(); //At the moment only a count 0 -> 255
We don't think below function is robust, there need consider PIT timer overrun.
We recommend set a global variable as counter, which add 1 every set time interval passed (for example 200us).
/*
* @brief Function to get the time difference.
* @return uint16_t µs_difference -> The time difference in µs.
*/
uint16_t TimersAndCo_GetTimeDifference(void)
{
uint64_t currentTimerValue = COUNT_TO_USEC(PIT_GetCurrentTimerCount(PIT, PIT_TIME_DIFFERENCE_CHANNEL), PIT_SOURCE_CLOCK);
uint64_t timeDifference = lastTimerValue - currentTimerValue;
lastTimerValue = currentTimerValue;
//return (uint16_t)timeDifference;
return intervalCount;
}
Then use that counter variable will check if there with the data lost issue.
Thank you for the attention.
Have a great day,
Mike
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------