# xTaskGetTickCount always returns 0

**URL:** <https://forums.freertos.org/t/xtaskgettickcount-always-returns-0/6589>\
**Category:** Kernel\
**Created:** [May 24, 2017, 8:18am UTC](https://forums.freertos.org/t/xtaskgettickcount-always-returns-0/6589 "2017-05-24T08:18:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 24, 2017, 8:18am UTC](https://forums.freertos.org/t/xtaskgettickcount-always-returns-0/6589/1 "2017-05-24T08:18:42Z")

</div>

**[ramawidi](https://sourceforge.net/u/ramawidi/)** wrote on [Wednesday, May 24, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/eb173cf7/#08f6):

Hi, I working on STM32F4 Discovery with FreeRTOS ver 9. I use xTaskGetTickCount to see how long my task is working on. But xTaskGetTickCount always returns 0. This is my task code

void test\_print(void)  
{  
uint32\_t wake\_time,temp1,temp2;  
const uint32\_t period = 100;  
char buff[32];

```
wake_time = xTaskGetTickCount();
while(1)
{
	tamp1 = xTaskGetTickCount();
	sprintf(buff,"Tick1 = %u\n",temp1);
	USART_puts(buff);
	
	USART_puts("aaaaaaaaaaa\n");
	//vTaskDelay(1000);
	delay_dw(500);
	
	tamp2 = xTaskGetTickCount();
	sprintf(buff,"Tick2 = %u\n",temp2);
	
	USART_puts(buff);
	vTaskDelayUntil(&wake_time,period);
}

```

}

Anyone help?

Thank You

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 24, 2017, 9:00am UTC](https://forums.freertos.org/t/xtaskgettickcount-always-returns-0/6589/2 "2017-05-24T09:00:57Z")

</div>

**[omar93](https://sourceforge.net/u/omar93/)** wrote on [Wednesday, May 24, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/eb173cf7/#1a93):

Hi,

I am working with Xilinx Zynq ZC702 and I have the same problem…

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 24, 2017, 11:26am UTC](https://forums.freertos.org/t/xtaskgettickcount-always-returns-0/6589/3 "2017-05-24T11:26:20Z")

</div>

**[kenchang1](https://sourceforge.net/u/kenchang1/)** wrote on [Wednesday, May 24, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/eb173cf7/#da1d):

Does the code compile? Any warnings (implicit declaration of variables)? TYPO: tamp1, tamp2 should be temp1, temp2.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [May 24, 2017, 12:43pm UTC](https://forums.freertos.org/t/xtaskgettickcount-always-returns-0/6589/4 "2017-05-24T12:43:26Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Wednesday, May 24, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/eb173cf7/#da1d/efeb):

Sounds like the tick interrupt is not running. Is it installed? See the first question of the FAQ page “my application does not run, what could be wrong?”. I think there is a link to the page in the comments at the top of each source file.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 28, 2017, 6:35am UTC](https://forums.freertos.org/t/xtaskgettickcount-always-returns-0/6589/5 "2017-05-28T06:35:40Z")

</div>

**[ramawidi](https://sourceforge.net/u/ramawidi/)** wrote on [Sunday, May 28, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/eb173cf7/#da1d/f3cc):

No I don’t have any warnings. Sorry for the Typo. Actually tamp1 & tamp2 is temp1 & temp2. And I’m sorry, I don’t get what do you mean about installed? Do you mean Tick is installed? correct me if I’m wrong

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [May 28, 2017, 7:28am UTC](https://forums.freertos.org/t/xtaskgettickcount-always-returns-0/6589/6 "2017-05-28T07:28:14Z")

</div>

**[hs2sf](https://sourceforge.net/u/hs2sf/)** wrote on [Sunday, May 28, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/eb173cf7/#da1d/f3cc/a65f):

Question is if the SysTick interrupt / its ISR is properly installed.  
Note that this is port / BSP specific.  
For STMF4 ie. Cortex-M4 architecture you have to prepare the exception vector table containing the interrupt handlers used by your application.  
It should at least contain the entries required by FreeRTOS to run.  
These are defined in your FreeRTOSConfig.h:

```auto
/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS standard names. */
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler

```

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 31, 2017, 3:54am UTC](https://forums.freertos.org/t/xtaskgettickcount-always-returns-0/6589/7 "2017-05-31T03:54:52Z")

</div>

**[ramawidi](https://sourceforge.net/u/ramawidi/)** wrote on [Wednesday, May 31, 2017](https://sourceforge.net/p/freertos/discussion/382005/thread/eb173cf7/#da1d/f3cc/a65f/4bf6):

Hi, HS2  
When I checked my FreeRTOSConfig.h those 3 lines is not available so I add it and works. Thank you so much for your help

Regards,  
Rama
