FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [April 2005 Threads] Adding time stamp for my thread executionsPosted by Nobody/Anonymous on April 26, 2005 Hi!
I need to add some time stamps for my sampling, for this I have used following code:
xLastWakeTime = xTaskGetTickCount();
for(;;) { portTickType old_wake_time = xLastWakeTime; // Wait for the next cycle. vTaskDelayUntil( &xLastWakeTime, xFrequency ); double millisec=(double)((xLastWakeTime-old_wake_time)/portTICK_RATE_MS); char data[40]; sprintf(data, " X =%d; Y =%d; Z =%d\r\n", millisek, acc[1], acc[2]);
Im getting strange values... Why doesn't this work?
Thanks! MB
RE: Adding time stamp for my thread executionsPosted by Richard on April 26, 2005 Hi,
Which port and compiler are you using?
A couple of points:
char data[40] - do you have enough stack space to allocate 40 bytes? Maybe static char data[40] would help. sprintf will use lots of stack also.
In the sprintf you are using %d (int format) to print a double.
Lastly - I presume you are wanting a time stamp in milliseconds? portTICK_RATE_MS is the time in MS between each tick. If you have a tick rate of 500hz (for example) then portTICK_RATE_MS will be 2. Then, if 10 ticks have passed between xLastWakeTime and old_wake_time this is 10 * 2 milliseconds. 10 / 2 will give you 5ms, which I presume is not what you want.
Regards.
RE: Adding time stamp for my thread executionPosted by Nobody/Anonymous on April 27, 2005 Hello!
Thank you for helping med with my bloopers, problem solved!
//MB
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|