# Increasing the portTICK\_RATE\_HZ

**URL:** <https://forums.freertos.org/t/increasing-the-porttick-rate-hz/1677>\
**Category:** Kernel\
**Created:** [November 12, 2004, 1:33pm UTC](https://forums.freertos.org/t/increasing-the-porttick-rate-hz/1677 "2004-11-12T13:33:52Z")\
**Posts on this page:** 10\
**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:** [November 12, 2004, 1:33pm UTC](https://forums.freertos.org/t/increasing-the-porttick-rate-hz/1677/1 "2004-11-12T13:33:52Z")

</div>

**[teunvandeberg](https://sourceforge.net/u/teunvandeberg/)** wrote on [Friday, November 12, 2004](https://sourceforge.net/p/freertos/discussion/382005/thread/499e26b3/#e7f7):

Hello,

I need to increase the portTICK\_RATE\_HZ. This should be okay because I am using a LPC2292, which runs at 58.982.400Hz. I need a portTICK\_RATE\_HZ of at least 600.000 Hz but for convenience I used 1.000.000Hz. In order to achieve this I changed or added the following defines:

#define portTICK\_RATE\_HZ&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( ( portTickType ) 1000000 )

#define portTICK\_RATE\_MICROS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( ( portTickType ) 1000000 / portTICK\_RATE\_HZ )  
#define portTICK\_RATE\_MS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( portTickType )( portTICK\_RATE\_MICROS \* 1000 )

However having done this, FreeRTOS doesn’t run. Can anyone give some assistance?

Thank you in advance!

Kind regards,  
Teun van de Berg

---

<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:** [November 12, 2004, 1:50pm UTC](https://forums.freertos.org/t/increasing-the-porttick-rate-hz/1677/2 "2004-11-12T13:50:41Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, November 12, 2004](https://sourceforge.net/p/freertos/discussion/382005/thread/499e26b3/#e7f7/11f0):

I don’t think it would be possible to have a 1MHz tick with a 60MHz clock.&nbsp; This would only allow 60 clock cycles per tick.

Why do you want the tick rate so high, what function are you performing?&nbsp; Maybe there is another way of achieving your objectives?

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 12, 2004, 1:55pm UTC](https://forums.freertos.org/t/increasing-the-porttick-rate-hz/1677/3 "2004-11-12T13:55:36Z")

</div>

**[teunvandeberg](https://sourceforge.net/u/teunvandeberg/)** wrote on [Friday, November 12, 2004](https://sourceforge.net/p/freertos/discussion/382005/thread/499e26b3/#e7f7/db5d):

I’m sorry. I included a 0 to many. It should have been 60.000. But for convinience I set the tickrate to 100.000. We need this to be able toll a pin faster than 30kHz and still have (block) time for calculations.

---

<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:** [November 12, 2004, 2:28pm UTC](https://forums.freertos.org/t/increasing-the-porttick-rate-hz/1677/4 "2004-11-12T14:28:14Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, November 12, 2004](https://sourceforge.net/p/freertos/discussion/382005/thread/499e26b3/#e7f7/db5d/13ee):

60K is still very fast.&nbsp; I’m not sure if it is possible.&nbsp; You presumable have to process each polled input and react somehow to changes.

portTICK\_RATE\_MS would be less than 1 - and as this is a integral variable this cannot be.&nbsp; However, this would not really matter as the constant is not used by the kernel - only the demo program as a convenient way of generating time values.

If setting 30KHz was possible you would then have to modify the kernel slightly to ensure that the poll task was woken every tick, and ensure that the poll task had completed and blocked again before the next tick.&nbsp; This could be done with a semaphore and a tick hook.

Alternatively, would it be possible to:

+ Have the input you are monitoring on an external interrupt so you need only process it when it’s state changes.

+ If these are the only function then maybe if you don’t use a kernel, have your calculation running in a continuous loop, and have the pin being polled in a simple timer ISR (if this can be done at 30KHz which is also a bit doubtfull).

+ Use an FPGA instead of a microcontroller.

+ Have a lower priority task poll the input - and have it preempted by the calculation?

+ Have the poll take place as a tick switch hook?

Regards,  
Richard.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 12, 2004, 3:17pm UTC](https://forums.freertos.org/t/increasing-the-porttick-rate-hz/1677/5 "2004-11-12T15:17:04Z")

</div>

**[teunvandeberg](https://sourceforge.net/u/teunvandeberg/)** wrote on [Friday, November 12, 2004](https://sourceforge.net/p/freertos/discussion/382005/thread/499e26b3/#e7f7/7e9a):

Thank you for your reply. To answer your questions:

It is not possible to attach it to a external interrupt because the layout for the board has already been made.

We cannot use an FPGA as this doesnt suit our requirements.

The polling task must have the highest priority, as this is the most important task on our system.

The last option might be possible. I’ll keep it in mind.

As I am currently experiencing problems with an increased tick rate I’ll try to use timer 1 to generate an interrupts for a polling mechanism.

Kind Regards,  
Teun van de Berg

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 2, 2005, 1:30pm UTC](https://forums.freertos.org/t/increasing-the-porttick-rate-hz/1677/6 "2005-05-02T13:30:56Z")

</div>

**nobody** wrote on [Monday, May 02, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/499e26b3/#e7f7/db5d/13ee/2c0d):

Is it correct that freeRTOS will not run with standard setup and a portTICK\_RATE\_HZ of 1 kHz, meaning a resolution of&nbsp; 1 ms??

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 2, 2005, 2:25pm UTC](https://forums.freertos.org/t/increasing-the-porttick-rate-hz/1677/7 "2005-05-02T14:25:17Z")

</div>

**nobody** wrote on [Monday, May 02, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/499e26b3/#e7f7/db5d/13ee/2c0d/531e):

This is definitely not true - all the demo applications use a tick rate of 1KHz.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 2, 2005, 3:21pm UTC](https://forums.freertos.org/t/increasing-the-porttick-rate-hz/1677/8 "2005-05-02T15:21:28Z")

</div>

**nobody** wrote on [Monday, May 02, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/499e26b3/#e7f7/db5d/13ee/2c0d/531e/6843):

portTICK\_RATE\_HZ is port specific right?? Using SAM7 this is set to 250 Hz/4 ms, my apps runs without any problems under 1 KHz but above that nothing happens, why is that? I actually need it to run under 2 KHz in order to synchronize sampling… Is this possible or do I get to much overhead already above 1 KHz?

//MB

---

<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 2, 2005, 3:46pm UTC](https://forums.freertos.org/t/increasing-the-porttick-rate-hz/1677/9 "2005-05-02T15:46:11Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Monday, May 02, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/499e26b3/#e7f7/db5d/13ee/2c0d/531e/6843/a52a):

portTICK\_RATE\_HZ is actually application specific&nbsp; in that each application will want to change the value.&nbsp; V3.0.0 has therefore renamed the constant to configTICK\_RATE\_HZ and moved the definition out of portmacro.h.

2KHz should not be a problem for the SAM7 assuming it is running at a high clock frequency.&nbsp; The high tick rate will however decrease efficiency as the kernel will be using more CPU time.

portTICK\_RATE\_MS is defined as (1000/portTICK\_RATE\_HZ) so will therefore give 0 (integer) for a portTICK\_RATE\_HZ of 2000.&nbsp; This will be causing you the problem.

portTICK\_RATE\_MS is not a required definition and is really only included for the purpose of making the demo application a little more readable.&nbsp; It is just the number of ticks that occur in a millisecond.&nbsp; It is used by the demo application to calculate delay times in ticks (required by the API) rather than ms.&nbsp; It is not used by the kernel itself \*\*\*BUT IS USED BY THE SAM7 PORT TO CALCULATE THE portPIT\_COUNTER\_VALUE CONSTANT\*\*\*.&nbsp;&nbsp; portPIT\_COUNTER\_VALUE is used within port.c to setup the timer interrupt to generate ticks at the required frequency.&nbsp; If the portTICK\_RATE\_HZ is greater than 1000 then the timer will not get set up&nbsp; hence your problem.

You will have to replace all occurrences of portTICK\_RATE\_MS with the correct value.&nbsp; The only place you definitely have to change is in port.c&nbsp; but if your application makes use of portTICK\_RATE\_MS or makes used of demo application files that use the definition&nbsp; then these too will need changing.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 2, 2005, 4:20pm UTC](https://forums.freertos.org/t/increasing-the-porttick-rate-hz/1677/10 "2005-05-02T16:20:20Z")

</div>

**nobody** wrote on [Monday, May 02, 2005](https://sourceforge.net/p/freertos/discussion/382005/thread/499e26b3/#e7f7/db5d/13ee/2c0d/531e/6843/a52a/97b3):

OK! I get it, changed it and now it runs… Very good!

I have to say that the response time on this forum is exceptionally good, it really helps! Thanks!
