Community news, upcoming events and general discussions
Threads: 36 Posts: 88
Get technical support from the community
Threads: 1427 Posts: 7608
Threads: 18 Posts: 64
Tell us how to make XDK better!
Threads: 36 Posts: 119
Share and discuss community member projects
Threads: 81 Posts: 350
I am using the following code to print "hello world" for one second with a period of 1 milli second. So in theory, there should be 1000 hello worlds printed.
#define TIMERBLOCKTIME UINT32_C(0Xffff) #define TIMER_AUTO_RELOAD_ON pdTRUE #define MILLI_SECOND(x) ((portTickType) (x)/portTICK_RATE_MS )
applicationTimer = xTimerCreate((char* const) "Application to print hello world",
but it seems the xTimerStop is not able to stop applicationTimer and it keeps on printing hello world infinte time. Where as if I put time period as 2 or more milli_second, it works absolutely fine. Can anyone help me with this?
Hello Ankit Chanda,
Regarding the timer period:
If the timer must expire after 1000 ticks, then simply set xTimerPeriod to 1000. Alternatively, if the timer must expire after 1000ms, then set xTimerPeriod to pdMS_TO_TICKS( 1000 ). pdMS_TO_TICKS() can only be used if configTICK_RATE_HZ is less than or equal to 1000. configTICK_RATE_HZ is defined in FreeRTOSConfig.h under xdk110/Common/config/AmazonFreeRTOS/FreeRTOS/FreeRTOSConfig.h
If I set the xTimerPeriod to 1000ms, it would print helloworld every 1 second. But what I want is to print helloworld every 1 millisecond for a total period of 1 second. Hence, I stop the timer after 1 second. Basically, My target is to get acceleration data at a sampling rate of 1000. So, this one is a simpler version. Its easier to implement in MITA. But I dont know, how shall I ipmlement this timer task. Because if I use the command every 1 millisecond, then it will loop infinitely. For example; the following code
What I want is to stop the every 1 milliseconds block after 1 second. But I dont know how to do that.