Skip to content

FreeRTOS.ino: fix usage of vTaskDelay #7418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2022
Merged

Conversation

WereCatf
Copy link
Contributor

The original code assumes 100Hz FreeRTOS tick rate and just supplies vTaskDelay with the assumed number of ticks required for the wanted delay. This patch simply fixes it to use portTICK_PERIOD_MS, thereby working correctly regardless of what tick rate FreeRTOS has been configured to run at.

Signed-off-by: Nita Vesa werecatf@outlook.com

The original code assumes 100Hz FreeRTOS tick rate and just supplies vTaskDelay with the assumed number of ticks required for the wanted delay. This patch simply fixes it to use portTICK_PERIOD_MS, thereby working correctly regardless of what tick rate FreeRTOS has been configured to run at.

Signed-off-by: Nita Vesa <werecatf@outlook.com>
@CLAassistant
Copy link

CLAassistant commented Oct 31, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@mrengineer7777 mrengineer7777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like original example would run faster than intended. Good fix. LGTM.

@me-no-dev
Copy link
Member

I agree that comments are not correct, but do keep in mind that Arduino runs with 1000Hz tick rate, so you do not really need to divide by portTICK_PERIOD_MS. vTaskDelay(1000) would delay for 1000 ms in Arduino

@me-no-dev me-no-dev self-requested a review November 2, 2022 08:37
@WereCatf
Copy link
Contributor Author

WereCatf commented Nov 2, 2022

so you do not really need to divide by portTICK_PERIOD_MS. vTaskDelay(1000) would delay for 1000 ms in Arduino

No, you do not, but if someone is looking at these examples trying to learn something, it's IMHO best to show them a way of using vTaskDelay where it works correctly regardless of what the FreeRTOS tick rate has been configured at. It translates better to other microcontrollers and environments that way as well.

@me-no-dev
Copy link
Member

it's IMHO best to show them a way of using vTaskDelay where it works correctly regardless of what the FreeRTOS tick rate has been configured at.

Agreed and approved :)

@me-no-dev me-no-dev merged commit d3ccd2a into espressif:master Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants