need to calculate the elapsed time in milliseconds between two points in my code(using STM32F103C8T)
@Middleware & OS
hello guys, I am using an STM32F103C8T6 with FreeRTOS, and I need to calculate the elapsed time in milliseconds between two points in my code.
my code snippet below captures the tick count but does not convert it to milliseconds.
static unsigned long gMSTP_timer_tick = 0;
void MSTP_timer_reset() {
gMSTP_timer_tick = xTaskGetTickCount();
}
FLOAT32 MSTP_timer_difference() {
unsigned long difference = xTaskGetTickCount() - gMSTP_timer_tick;
gMSTP_timer_tick += difference;
return (FLOAT32) difference;
}
1 Reply
@Enthernet Code
To convert the tick count to milliseconds, you need to use the FreeRTOS function portTICK_PERIOD_MS to get the tick period in milliseconds.