{"id":110,"date":"2026-03-31T23:19:31","date_gmt":"2026-03-31T15:19:31","guid":{"rendered":"https:\/\/granddream.top\/?p=110"},"modified":"2026-04-01T00:20:42","modified_gmt":"2026-03-31T16:20:42","slug":"freertos-%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0","status":"publish","type":"post","link":"https:\/\/granddream.top\/index.php\/2026\/03\/31\/freertos-%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0\/","title":{"rendered":"FreeRTOS \u5b66\u4e60\u7b14\u8bb0"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1. FreeRTOS \u662f\u4ec0\u4e48<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5d4c\u5165\u5f0f<strong>\u8f7b\u91cf\u7ea7\u5b9e\u65f6\u64cd\u4f5c\u7cfb\u7edf\u5185\u6838\uff08RTOS\uff09<\/strong><\/li>\n\n\n\n<li>\u7528\u4e8e\u5728\u5355\u7247\u673a\uff08STM32\/ESP32 \u7b49\uff09\u4e0a\u5b9e\u73b0<strong>\u591a\u4efb\u52a1\u3001\u4f18\u5148\u7ea7\u8c03\u5ea6\u3001\u5b9e\u65f6\u54cd\u5e94<\/strong><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">2. \u88f8\u673a\uff08\u4e0d\u7528 RTOS\uff09 vs FreeRTOS<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u88f8\u673a<\/strong>\n<ul class=\"wp-block-list\">\n<li>\u4e00\u4e2a <code>while(1)<\/code> \u5faa\u73af\u91cc\u987a\u5e8f\u6267\u884c\u6240\u6709\u529f\u80fd<\/li>\n\n\n\n<li>\u4efb\u52a1\u963b\u585e\u4f1a\u5bfc\u81f4\u6574\u4e2a\u7a0b\u5e8f\u5361\u4f4f<\/li>\n\n\n\n<li>\u65e0\u4f18\u5148\u7ea7\uff0c\u5b9e\u65f6\u6027\u5dee<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>FreeRTOS<\/strong>\n<ul class=\"wp-block-list\">\n<li>\u628a\u529f\u80fd\u62c6\u6210<strong>\u591a\u4e2a\u72ec\u7acb\u4efb\u52a1<\/strong><\/li>\n\n\n\n<li>\u652f\u6301<strong>\u4f18\u5148\u7ea7<\/strong>\uff0c\u9ad8\u4f18\u5148\u7ea7\u4efb\u52a1\u53ef\u62a2\u5360\u6267\u884c<\/li>\n\n\n\n<li>\u4efb\u52a1\u4e92\u4e0d\u5e72\u6270\uff0c\u7ed3\u6784\u6e05\u6670\uff0c\u9002\u5408\u590d\u6742\u9879\u76ee<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">3. \u4e24\u4e2a\u6700\u6838\u5fc3\u7cfb\u7edf\u51fd\u6570<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong><code>xTaskCreate(...)<\/code><\/strong>\n<ul class=\"wp-block-list\">\n<li>FreeRTOS \u5b98\u65b9\u63d0\u4f9b\u7684 API \u51fd\u6570<\/li>\n\n\n\n<li>\u4f5c\u7528\uff1a<strong>\u521b\u5efa\u4e00\u4e2a\u4efb\u52a1<\/strong>\uff0c\u544a\u8bc9\u7cfb\u7edf\u8981\u8fd0\u884c\u54ea\u4e2a\u51fd\u6570\u3001\u4f18\u5148\u7ea7\u3001\u6808\u5927\u5c0f\u7b49<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong><code>vTaskStartScheduler()<\/code><\/strong>\n<ul class=\"wp-block-list\">\n<li>FreeRTOS \u5b98\u65b9\u63d0\u4f9b\u7684 API \u51fd\u6570<\/li>\n\n\n\n<li>\u4f5c\u7528\uff1a<strong>\u542f\u52a8\u4efb\u52a1\u8c03\u5ea6\u5668<\/strong><\/li>\n\n\n\n<li>\u8c03\u7528\u540e\u7cfb\u7edf\u5f00\u59cb<strong>\u81ea\u52a8\u5207\u6362\u3001\u8c03\u5ea6\u4efb\u52a1<\/strong>\uff0c\u7a0b\u5e8f\u6b63\u5f0f\u8fdb\u5165 RTOS \u8fd0\u884c\u6a21\u5f0f<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">4. \u6807\u51c6 main \u51fd\u6570\u7ed3\u6784<\/h2>\n\n\n\n<p>c<\/p>\n\n\n\n<p>\u8fd0\u884c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int main(void)\n{\n    \/\/ 1. \u521b\u5efa\u4efb\u52a1\n    xTaskCreate(LED_Task,  \"LED\",  128, NULL, 1, NULL);\n    xTaskCreate(Key_Task,  \"KEY\",  128, NULL, 2, NULL);\n    xTaskCreate(UART_Task, \"UART\", 128, NULL, 1, NULL);\n\n    \/\/ 2. \u542f\u52a8\u8c03\u5ea6\u5668\uff0c\u7cfb\u7edf\u81ea\u52a8\u8fd0\u884c\n    vTaskStartScheduler();\n\n    \/\/ 3. \u6b63\u5e38\u4e0d\u4f1a\u6267\u884c\u5230\u8fd9\u91cc\n    while(1);\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">5. \u4e00\u53e5\u8bdd\u603b\u7ed3<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>xTaskCreate<\/code>\uff1a<strong>\u521b\u5efa\u4efb\u52a1<\/strong><\/li>\n\n\n\n<li><code>vTaskStartScheduler<\/code>\uff1a<strong>\u542f\u52a8 RTOS\uff0c\u8ba9\u4efb\u52a1\u81ea\u52a8\u8c03\u5ea6\u8fd0\u884c<\/strong><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. FreeRTOS \u662f\u4ec0\u4e48 2. \u88f8\u673a\uff08\u4e0d\u7528 RTOS\uff09 vs FreeRTOS 3. \u4e24\u4e2a\u6700\u6838\u5fc3\u7cfb\u7edf\u51fd\u6570 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":119,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10],"class_list":["post-110","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-article","tag-10"],"_links":{"self":[{"href":"https:\/\/granddream.top\/index.php\/wp-json\/wp\/v2\/posts\/110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/granddream.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/granddream.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/granddream.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/granddream.top\/index.php\/wp-json\/wp\/v2\/comments?post=110"}],"version-history":[{"count":1,"href":"https:\/\/granddream.top\/index.php\/wp-json\/wp\/v2\/posts\/110\/revisions"}],"predecessor-version":[{"id":111,"href":"https:\/\/granddream.top\/index.php\/wp-json\/wp\/v2\/posts\/110\/revisions\/111"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/granddream.top\/index.php\/wp-json\/wp\/v2\/media\/119"}],"wp:attachment":[{"href":"https:\/\/granddream.top\/index.php\/wp-json\/wp\/v2\/media?parent=110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/granddream.top\/index.php\/wp-json\/wp\/v2\/categories?post=110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/granddream.top\/index.php\/wp-json\/wp\/v2\/tags?post=110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}