<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>prioridades de tarefas - MCU &amp; FPGA</title>
	<atom:link href="https://mcu.tec.br/tags/prioridades-de-tarefas/feed/" rel="self" type="application/rss+xml" />
	<link>https://mcu.tec.br</link>
	<description>Microcontroladores &#38; FPGA</description>
	<lastBuildDate>Wed, 07 Jan 2026 00:43:30 +0000</lastBuildDate>
	<language>pt-BR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>

<image>
	<url>https://mcu.tec.br/wp-content/uploads/2025/02/Robo-para-o-site-MCU.tec_.br-512x512-1-150x150.png</url>
	<title>prioridades de tarefas - MCU &amp; FPGA</title>
	<link>https://mcu.tec.br</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Como Criar Tarefas e Soft Timers no FreeRTOS: Guia Prático e Didático para Sistemas Embarcados</title>
		<link>https://mcu.tec.br/rtos/como-criar-tarefas-e-soft-timers-no-freertos-guia-pratico-e-didatico-para-sistemas-embarcados/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=como-criar-tarefas-e-soft-timers-no-freertos-guia-pratico-e-didatico-para-sistemas-embarcados</link>
		
		<dc:creator><![CDATA[Carlos Delfino]]></dc:creator>
		<pubDate>Fri, 09 Jan 2026 18:45:24 +0000</pubDate>
				<category><![CDATA[RTOS]]></category>
		<category><![CDATA[arquitetura embarcada]]></category>
		<category><![CDATA[escalonador FreeRTOS]]></category>
		<category><![CDATA[event groups]]></category>
		<category><![CDATA[filas FreeRTOS]]></category>
		<category><![CDATA[freertos]]></category>
		<category><![CDATA[heap FreeRTOS]]></category>
		<category><![CDATA[prioridades de tarefas]]></category>
		<category><![CDATA[programação em tempo real]]></category>
		<category><![CDATA[RTOS embarcado]]></category>
		<category><![CDATA[soft timers FreeRTOS]]></category>
		<category><![CDATA[stack no FreeRTOS]]></category>
		<category><![CDATA[tarefas no FreeRTOS]]></category>
		<category><![CDATA[task notification]]></category>
		<category><![CDATA[Timer Service Task]]></category>
		<category><![CDATA[timers de software]]></category>
		<guid isPermaLink="false">https://mcu.tec.br/?p=1016</guid>

					<description><![CDATA[<p>Este artigo apresenta um guia completo e didático sobre como criar e gerenciar tarefas e soft timers no FreeRTOS, explicando conceitos fundamentais de escalonamento, prioridades, dimensionamento de stack e comunicação entre timers e tarefas. Com exemplos práticos em C para microcontroladores, o conteúdo mostra como estruturar arquiteturas embarcadas reais, eficientes e escaláveis, utilizando boas práticas de projeto para evitar bloqueios, reduzir consumo de CPU e aumentar a previsibilidade temporal. Ideal para estudantes, desenvolvedores de firmware e profissionais que desejam dominar o uso do FreeRTOS em aplicações embarcadas modernas.</p>
<p>The post <a href="https://mcu.tec.br/rtos/como-criar-tarefas-e-soft-timers-no-freertos-guia-pratico-e-didatico-para-sistemas-embarcados/">Como Criar Tarefas e Soft Timers no FreeRTOS: Guia Prático e Didático para Sistemas Embarcados</a> first appeared on <a href="https://mcu.tec.br">MCU & FPGA</a>.</p>]]></description>
										<content:encoded><![CDATA[<div class="root-eb-toc-8ti67 wp-block-essential-blocks-table-of-contents"><div class="eb-parent-wrapper eb-parent-eb-toc-8ti67 "><div class="eb-toc-container eb-toc-8ti67  eb-toc-is-not-sticky eb-toc-not-collapsible eb-toc-initially-not-collapsed eb-toc-scrollToTop style-1 list-style-none" data-scroll-top="false" data-scroll-top-icon="fas fa-angle-up" data-collapsible="false" data-sticky-hide-mobile="false" data-sticky="false" data-scroll-target="scroll_to_toc" data-copy-link="false" data-editor-type="" data-hide-desktop="false" data-hide-tab="false" data-hide-mobile="false" data-itemcollapsed="false" data-highlight-scroll="false"><div class="eb-toc-header"><h2 class="eb-toc-title">Table of Contents</h2></div><div class="eb-toc-wrapper " data-headers="[{&quot;level&quot;:2,&quot;content&quot;:&quot;Conceito de Tarefas no FreeRTOS e Estrutura B\u00e1sica&quot;,&quot;text&quot;:&quot;Conceito de Tarefas no FreeRTOS e Estrutura B\u00e1sica&quot;,&quot;link&quot;:&quot;eb-table-content-0&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Assinatura de uma tarefa no FreeRTOS&quot;,&quot;text&quot;:&quot;Assinatura de uma tarefa no FreeRTOS&quot;,&quot;link&quot;:&quot;assinatura-de-uma-tarefa-no-freertos&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Cria\u00e7\u00e3o de tarefas com xTaskCreate()&quot;,&quot;text&quot;:&quot;Cria\u00e7\u00e3o de tarefas com xTaskCreate()&quot;,&quot;link&quot;:&quot;eb-table-content-2&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Exemplo pr\u00e1tico: tarefa de LED&quot;,&quot;text&quot;:&quot;Exemplo pr\u00e1tico: tarefa de LED&quot;,&quot;link&quot;:&quot;eb-table-content-3&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Estados de uma tarefa no FreeRTOS&quot;,&quot;text&quot;:&quot;Estados de uma tarefa no FreeRTOS&quot;,&quot;link&quot;:&quot;estados-de-uma-tarefa-no-freertos&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;2 \u2013 Prioridades, Stack e Boas Pr\u00e1ticas na Cria\u00e7\u00e3o de Tarefas&quot;,&quot;text&quot;:&quot;2 \u2013 Prioridades, Stack e Boas Pr\u00e1ticas na Cria\u00e7\u00e3o de Tarefas&quot;,&quot;link&quot;:&quot;eb-table-content-5&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Prioridades de tarefas&quot;,&quot;text&quot;:&quot;Prioridades de tarefas&quot;,&quot;link&quot;:&quot;prioridades-de-tarefas&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Stack de tarefas: como dimensionar corretamente&quot;,&quot;text&quot;:&quot;Stack de tarefas: como dimensionar corretamente&quot;,&quot;link&quot;:&quot;stack-de-tarefas-como-dimensionar-corretamente&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Como estimar o tamanho da stack&quot;,&quot;text&quot;:&quot;Como estimar o tamanho da stack&quot;,&quot;link&quot;:&quot;como-estimar-o-tamanho-da-stack&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Stack overflow e mecanismos de prote\u00e7\u00e3o&quot;,&quot;text&quot;:&quot;Stack overflow e mecanismos de prote\u00e7\u00e3o&quot;,&quot;link&quot;:&quot;eb-table-content-9&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Heap e cria\u00e7\u00e3o din\u00e2mica de tarefas&quot;,&quot;text&quot;:&quot;Heap e cria\u00e7\u00e3o din\u00e2mica de tarefas&quot;,&quot;link&quot;:&quot;eb-table-content-10&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Boas pr\u00e1ticas fundamentais&quot;,&quot;text&quot;:&quot;Boas pr\u00e1ticas fundamentais&quot;,&quot;link&quot;:&quot;eb-table-content-11&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;Soft Timers no FreeRTOS: Conceito, Arquitetura e Diferen\u00e7as para Tarefas&quot;,&quot;text&quot;:&quot;Soft Timers no FreeRTOS: Conceito, Arquitetura e Diferen\u00e7as para Tarefas&quot;,&quot;link&quot;:&quot;eb-table-content-12&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;O que \u00e9 um Soft Timer&quot;,&quot;text&quot;:&quot;O que \u00e9 um Soft Timer&quot;,&quot;link&quot;:&quot;eb-table-content-13&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Timer Service Task&quot;,&quot;text&quot;:&quot;Timer Service Task&quot;,&quot;link&quot;:&quot;timer-service-task&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Tipos de Soft Timers&quot;,&quot;text&quot;:&quot;Tipos de Soft Timers&quot;,&quot;link&quot;:&quot;tipos-de-soft-timers&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Cria\u00e7\u00e3o de um Soft Timer&quot;,&quot;text&quot;:&quot;Cria\u00e7\u00e3o de um Soft Timer&quot;,&quot;link&quot;:&quot;eb-table-content-16&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Exemplo pr\u00e1tico: Soft Timer peri\u00f3dico&quot;,&quot;text&quot;:&quot;Exemplo pr\u00e1tico: Soft Timer peri\u00f3dico&quot;,&quot;link&quot;:&quot;eb-table-content-17&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;O que N\u00c3O fazer em callbacks de Soft Timer&quot;,&quot;text&quot;:&quot;O que N\u00c3O fazer em callbacks de Soft Timer&quot;,&quot;link&quot;:&quot;eb-table-content-18&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Compara\u00e7\u00e3o: Tarefa vs Soft Timer&quot;,&quot;text&quot;:&quot;Compara\u00e7\u00e3o: Tarefa vs Soft Timer&quot;,&quot;link&quot;:&quot;eb-table-content-19&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;Comunica\u00e7\u00e3o entre Soft Timers e Tarefas no FreeRTOS&quot;,&quot;text&quot;:&quot;Comunica\u00e7\u00e3o entre Soft Timers e Tarefas no FreeRTOS&quot;,&quot;link&quot;:&quot;eb-table-content-20&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Comunica\u00e7\u00e3o usando Task Notifications&quot;,&quot;text&quot;:&quot;Comunica\u00e7\u00e3o usando Task Notifications&quot;,&quot;link&quot;:&quot;eb-table-content-21&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Callback do timer notificando uma tarefa&quot;,&quot;text&quot;:&quot;Callback do timer notificando uma tarefa&quot;,&quot;link&quot;:&quot;callback-do-timer-notificando-uma-tarefa&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Tarefa aguardando a notifica\u00e7\u00e3o&quot;,&quot;text&quot;:&quot;Tarefa aguardando a notifica\u00e7\u00e3o&quot;,&quot;link&quot;:&quot;eb-table-content-23&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Comunica\u00e7\u00e3o usando Filas (Queues)&quot;,&quot;text&quot;:&quot;Comunica\u00e7\u00e3o usando Filas (Queues)&quot;,&quot;link&quot;:&quot;eb-table-content-24&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Callback enviando dados para a fila&quot;,&quot;text&quot;:&quot;Callback enviando dados para a fila&quot;,&quot;link&quot;:&quot;callback-enviando-dados-para-a-fila&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Tarefa consumindo a fila&quot;,&quot;text&quot;:&quot;Tarefa consumindo a fila&quot;,&quot;link&quot;:&quot;tarefa-consumindo-a-fila&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Comunica\u00e7\u00e3o usando Event Groups&quot;,&quot;text&quot;:&quot;Comunica\u00e7\u00e3o usando Event Groups&quot;,&quot;link&quot;:&quot;eb-table-content-27&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Callback setando um evento&quot;,&quot;text&quot;:&quot;Callback setando um evento&quot;,&quot;link&quot;:&quot;callback-setando-um-evento&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Tarefa aguardando o evento&quot;,&quot;text&quot;:&quot;Tarefa aguardando o evento&quot;,&quot;link&quot;:&quot;tarefa-aguardando-o-evento&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Compara\u00e7\u00e3o entre mecanismos&quot;,&quot;text&quot;:&quot;Compara\u00e7\u00e3o entre mecanismos&quot;,&quot;link&quot;:&quot;eb-table-content-30&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Padr\u00e3o arquitetural recomendado&quot;,&quot;text&quot;:&quot;Padr\u00e3o arquitetural recomendado&quot;,&quot;link&quot;:&quot;eb-table-content-31&quot;},{&quot;level&quot;:2,&quot;content&quot;:&quot;5 \u2013 Exemplo Completo: Arquitetura Real com Tarefas e Soft Timers no FreeRTOS&quot;,&quot;text&quot;:&quot;5 \u2013 Exemplo Completo: Arquitetura Real com Tarefas e Soft Timers no FreeRTOS&quot;,&quot;link&quot;:&quot;5-exemplo-completo-arquitetura-real-com-tarefas-e-soft-timers-no-freertos&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Cen\u00e1rio proposto&quot;,&quot;text&quot;:&quot;Cen\u00e1rio proposto&quot;,&quot;link&quot;:&quot;eb-table-content-33&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Diagrama l\u00f3gico da arquitetura&quot;,&quot;text&quot;:&quot;Diagrama l\u00f3gico da arquitetura&quot;,&quot;link&quot;:&quot;eb-table-content-34&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;C\u00f3digo completo do exemplo&quot;,&quot;text&quot;:&quot;C\u00f3digo completo do exemplo&quot;,&quot;link&quot;:&quot;eb-table-content-35&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Handles globais&quot;,&quot;text&quot;:&quot;Handles globais&quot;,&quot;link&quot;:&quot;handles-globais&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Callback do Soft Timer&quot;,&quot;text&quot;:&quot;Callback do Soft Timer&quot;,&quot;link&quot;:&quot;callback-do-soft-timer&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Tarefa de processamento&quot;,&quot;text&quot;:&quot;Tarefa de processamento&quot;,&quot;link&quot;:&quot;tarefa-de-processamento&quot;},{&quot;level&quot;:4,&quot;content&quot;:&quot;Inicializa\u00e7\u00e3o do sistema&quot;,&quot;text&quot;:&quot;Inicializa\u00e7\u00e3o do sistema&quot;,&quot;link&quot;:&quot;eb-table-content-39&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;An\u00e1lise t\u00e9cnica da solu\u00e7\u00e3o&quot;,&quot;text&quot;:&quot;An\u00e1lise t\u00e9cnica da solu\u00e7\u00e3o&quot;,&quot;link&quot;:&quot;eb-table-content-40&quot;},{&quot;level&quot;:3,&quot;content&quot;:&quot;Quando N\u00c3O usar Soft Timers&quot;,&quot;text&quot;:&quot;Quando N\u00c3O usar Soft Timers&quot;,&quot;link&quot;:&quot;eb-table-content-41&quot;}]" data-visible="[true,true,true,true,true,true]" data-delete-headers="[{&quot;label&quot;:&quot;Conceito de Tarefas no FreeRTOS e Estrutura B\u00e1sica&quot;,&quot;value&quot;:&quot;conceito-de-tarefas-no-freertos-e-estrutura-b\u00e1sica&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Assinatura de uma tarefa no FreeRTOS&quot;,&quot;value&quot;:&quot;assinatura-de-uma-tarefa-no-freertos&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Cria\u00e7\u00e3o de tarefas com xTaskCreate()&quot;,&quot;value&quot;:&quot;cria\u00e7\u00e3o-de-tarefas-com-xtaskcreate&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Exemplo pr\u00e1tico: tarefa de LED&quot;,&quot;value&quot;:&quot;exemplo-pr\u00e1tico-tarefa-de-led&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Estados de uma tarefa no FreeRTOS&quot;,&quot;value&quot;:&quot;estados-de-uma-tarefa-no-freertos&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;2 \u2013 Prioridades, Stack e Boas Pr\u00e1ticas na Cria\u00e7\u00e3o de Tarefas&quot;,&quot;value&quot;:&quot;2-prioridades-stack-e-boas-pr\u00e1ticas-na-cria\u00e7\u00e3o-de-tarefas&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Prioridades de tarefas&quot;,&quot;value&quot;:&quot;prioridades-de-tarefas&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Stack de tarefas: como dimensionar corretamente&quot;,&quot;value&quot;:&quot;stack-de-tarefas-como-dimensionar-corretamente&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Como estimar o tamanho da stack&quot;,&quot;value&quot;:&quot;como-estimar-o-tamanho-da-stack&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Stack overflow e mecanismos de prote\u00e7\u00e3o&quot;,&quot;value&quot;:&quot;stack-overflow-e-mecanismos-de-prote\u00e7\u00e3o&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Heap e cria\u00e7\u00e3o din\u00e2mica de tarefas&quot;,&quot;value&quot;:&quot;heap-e-cria\u00e7\u00e3o-din\u00e2mica-de-tarefas&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Boas pr\u00e1ticas fundamentais&quot;,&quot;value&quot;:&quot;boas-pr\u00e1ticas-fundamentais&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Soft Timers no FreeRTOS: Conceito, Arquitetura e Diferen\u00e7as para Tarefas&quot;,&quot;value&quot;:&quot;soft-timers-no-freertos-conceito-arquitetura-e-diferen\u00e7as-para-tarefas&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;O que \u00e9 um Soft Timer&quot;,&quot;value&quot;:&quot;o-que-\u00e9-um-soft-timer&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Timer Service Task&quot;,&quot;value&quot;:&quot;timer-service-task&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Tipos de Soft Timers&quot;,&quot;value&quot;:&quot;tipos-de-soft-timers&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Cria\u00e7\u00e3o de um Soft Timer&quot;,&quot;value&quot;:&quot;cria\u00e7\u00e3o-de-um-soft-timer&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Exemplo pr\u00e1tico: Soft Timer peri\u00f3dico&quot;,&quot;value&quot;:&quot;exemplo-pr\u00e1tico-soft-timer-peri\u00f3dico&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;O que N\u00c3O fazer em callbacks de Soft Timer&quot;,&quot;value&quot;:&quot;o-que-n\u00e3o-fazer-em-callbacks-de-soft-timer&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Compara\u00e7\u00e3o: Tarefa vs Soft Timer&quot;,&quot;value&quot;:&quot;compara\u00e7\u00e3o-tarefa-vs-soft-timer&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Comunica\u00e7\u00e3o entre Soft Timers e Tarefas no FreeRTOS&quot;,&quot;value&quot;:&quot;comunica\u00e7\u00e3o-entre-soft-timers-e-tarefas-no-freertos&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Comunica\u00e7\u00e3o usando Task Notifications&quot;,&quot;value&quot;:&quot;comunica\u00e7\u00e3o-usando-task-notifications&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Callback do timer notificando uma tarefa&quot;,&quot;value&quot;:&quot;callback-do-timer-notificando-uma-tarefa&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Tarefa aguardando a notifica\u00e7\u00e3o&quot;,&quot;value&quot;:&quot;tarefa-aguardando-a-notifica\u00e7\u00e3o&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Comunica\u00e7\u00e3o usando Filas (Queues)&quot;,&quot;value&quot;:&quot;comunica\u00e7\u00e3o-usando-filas-queues&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Callback enviando dados para a fila&quot;,&quot;value&quot;:&quot;callback-enviando-dados-para-a-fila&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Tarefa consumindo a fila&quot;,&quot;value&quot;:&quot;tarefa-consumindo-a-fila&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Comunica\u00e7\u00e3o usando Event Groups&quot;,&quot;value&quot;:&quot;comunica\u00e7\u00e3o-usando-event-groups&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Callback setando um evento&quot;,&quot;value&quot;:&quot;callback-setando-um-evento&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Tarefa aguardando o evento&quot;,&quot;value&quot;:&quot;tarefa-aguardando-o-evento&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Compara\u00e7\u00e3o entre mecanismos&quot;,&quot;value&quot;:&quot;compara\u00e7\u00e3o-entre-mecanismos&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Padr\u00e3o arquitetural recomendado&quot;,&quot;value&quot;:&quot;padr\u00e3o-arquitetural-recomendado&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;5 \u2013 Exemplo Completo: Arquitetura Real com Tarefas e Soft Timers no FreeRTOS&quot;,&quot;value&quot;:&quot;5-exemplo-completo-arquitetura-real-com-tarefas-e-soft-timers-no-freertos&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Cen\u00e1rio proposto&quot;,&quot;value&quot;:&quot;cen\u00e1rio-proposto&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Diagrama l\u00f3gico da arquitetura&quot;,&quot;value&quot;:&quot;diagrama-l\u00f3gico-da-arquitetura&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;C\u00f3digo completo do exemplo&quot;,&quot;value&quot;:&quot;c\u00f3digo-completo-do-exemplo&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Handles globais&quot;,&quot;value&quot;:&quot;handles-globais&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Callback do Soft Timer&quot;,&quot;value&quot;:&quot;callback-do-soft-timer&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Tarefa de processamento&quot;,&quot;value&quot;:&quot;tarefa-de-processamento&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Inicializa\u00e7\u00e3o do sistema&quot;,&quot;value&quot;:&quot;inicializa\u00e7\u00e3o-do-sistema&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;An\u00e1lise t\u00e9cnica da solu\u00e7\u00e3o&quot;,&quot;value&quot;:&quot;an\u00e1lise-t\u00e9cnica-da-solu\u00e7\u00e3o&quot;,&quot;isDelete&quot;:false},{&quot;label&quot;:&quot;Quando N\u00c3O usar Soft Timers&quot;,&quot;value&quot;:&quot;quando-n\u00e3o-usar-soft-timers&quot;,&quot;isDelete&quot;:false}]" data-smooth="true" data-top-offset=""><div class="eb-toc__list-wrap"><ul class="eb-toc__list"><li><a href="#eb-table-content-0">Conceito de Tarefas no FreeRTOS e Estrutura Básica</a><ul class="eb-toc__list"><li><a href="#assinatura-de-uma-tarefa-no-freertos">Assinatura de uma tarefa no FreeRTOS</a><li><a href="#eb-table-content-2">Criação de tarefas com xTaskCreate()</a><li><a href="#eb-table-content-3">Exemplo prático: tarefa de LED</a><li><a href="#estados-de-uma-tarefa-no-freertos">Estados de uma tarefa no FreeRTOS</a></li></ul><li><a href="#eb-table-content-5">2 – Prioridades, Stack e Boas Práticas na Criação de Tarefas</a><ul class="eb-toc__list"><li><a href="#prioridades-de-tarefas">Prioridades de tarefas</a><li><a href="#stack-de-tarefas-como-dimensionar-corretamente">Stack de tarefas: como dimensionar corretamente</a><ul class="eb-toc__list"><li><a href="#como-estimar-o-tamanho-da-stack">Como estimar o tamanho da stack</a></li></ul><li><a href="#eb-table-content-9">Stack overflow e mecanismos de proteção</a><li><a href="#eb-table-content-10">Heap e criação dinâmica de tarefas</a><li><a href="#eb-table-content-11">Boas práticas fundamentais</a></li></ul><li><a href="#eb-table-content-12">Soft Timers no FreeRTOS: Conceito, Arquitetura e Diferenças para Tarefas</a><ul class="eb-toc__list"><li><a href="#eb-table-content-13">O que é um Soft Timer</a><li><a href="#timer-service-task">Timer Service Task</a><li><a href="#tipos-de-soft-timers">Tipos de Soft Timers</a><li><a href="#eb-table-content-16">Criação de um Soft Timer</a><li><a href="#eb-table-content-17">Exemplo prático: Soft Timer periódico</a><li><a href="#eb-table-content-18">O que NÃO fazer em callbacks de Soft Timer</a><li><a href="#eb-table-content-19">Comparação: Tarefa vs Soft Timer</a></li></ul><li><a href="#eb-table-content-20">Comunicação entre Soft Timers e Tarefas no FreeRTOS</a><ul class="eb-toc__list"><li><a href="#eb-table-content-21">Comunicação usando Task Notifications</a><ul class="eb-toc__list"><li><a href="#callback-do-timer-notificando-uma-tarefa">Callback do timer notificando uma tarefa</a><li><a href="#eb-table-content-23">Tarefa aguardando a notificação</a></li></ul><li><a href="#eb-table-content-24">Comunicação usando Filas (Queues)</a><ul class="eb-toc__list"><li><a href="#callback-enviando-dados-para-a-fila">Callback enviando dados para a fila</a><li><a href="#tarefa-consumindo-a-fila">Tarefa consumindo a fila</a></li></ul><li><a href="#eb-table-content-27">Comunicação usando Event Groups</a><ul class="eb-toc__list"><li><a href="#callback-setando-um-evento">Callback setando um evento</a><li><a href="#tarefa-aguardando-o-evento">Tarefa aguardando o evento</a></li></ul><li><a href="#eb-table-content-30">Comparação entre mecanismos</a><li><a href="#eb-table-content-31">Padrão arquitetural recomendado</a></li></ul><li><a href="#5-exemplo-completo-arquitetura-real-com-tarefas-e-soft-timers-no-freertos">5 – Exemplo Completo: Arquitetura Real com Tarefas e Soft Timers no FreeRTOS</a><ul class="eb-toc__list"><li><a href="#eb-table-content-33">Cenário proposto</a><li><a href="#eb-table-content-34">Diagrama lógico da arquitetura</a><li><a href="#eb-table-content-35">Código completo do exemplo</a><ul class="eb-toc__list"><li><a href="#handles-globais">Handles globais</a><li><a href="#callback-do-soft-timer">Callback do Soft Timer</a><li><a href="#tarefa-de-processamento">Tarefa de processamento</a><li><a href="#eb-table-content-39">Inicialização do sistema</a></li></ul><li><a href="#eb-table-content-40">Análise técnica da solução</a><li><a href="#eb-table-content-41">Quando NÃO usar Soft Timers</a></li></ul></ul></div></div></div></div></div>


<h2 class="wp-block-heading"><strong>Conceito de Tarefas no FreeRTOS e Estrutura Básica</strong></h2>



<p class="wp-block-paragraph">Em um RTOS (Real-Time Operating System), o conceito central não é mais o <em>superloop</em>, mas sim a <strong>tarefa</strong> (<em>task</em>). Uma tarefa representa uma unidade independente de execução, com seu próprio contexto de CPU (registradores), sua própria pilha (<em>stack</em>) e um estado bem definido dentro do escalonador (<em>scheduler</em>). No FreeRTOS, tarefas são implementadas como <strong>funções C que nunca retornam</strong>, pois o controle do fluxo de execução é feito exclusivamente pelo kernel.</p>



<p class="wp-block-paragraph">Do ponto de vista conceitual, uma tarefa pode ser vista como uma <em>thread cooperativa/preemptiva</em>, dependendo da configuração do sistema. O FreeRTOS utiliza escalonamento <strong>preemptivo por prioridade</strong> (opcionalmente cooperativo), onde a tarefa de maior prioridade pronta para execução assume o processador. Isso permite modelar sistemas embarcados de forma mais determinística, separando claramente aquisição de dados, processamento, comunicação e controle.</p>



<h3 class="wp-block-heading"><strong>Assinatura de uma tarefa no FreeRTOS</strong></h3>



<p class="wp-block-paragraph">Toda tarefa no FreeRTOS segue a mesma assinatura básica:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>void vMinhaTarefa(void *pvParameters)
{
    for (;;)
    {
        /* Código da tarefa */
    }
}
</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff" tabindex="0"><code><span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">vMinhaTarefa</span><span style="color: #D8DEE9FF">(</span><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">*</span><span style="color: #D8DEE9">pvParameters</span><span style="color: #D8DEE9FF">)</span></span>
<span class="line"><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #81A1C1">for</span><span style="color: #D8DEE9FF"> (</span><span style="color: #81A1C1">;;</span><span style="color: #D8DEE9FF">)</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF">        </span><span style="color: #616E88">/* Código da tarefa */</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #ECEFF4">}</span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span>
<span class="line"></span></code></pre></div>



<p class="wp-block-paragraph">Alguns pontos importantes que merecem atenção:</p>



<ul class="wp-block-list">
<li>A função <strong>não deve retornar</strong>.</li>



<li>O parâmetro <code>pvParameters</code> é um ponteiro genérico (<code>void*</code>) que permite passar dados para a tarefa no momento da criação.</li>



<li>O loop infinito não é opcional: ele garante que a tarefa continue viva enquanto o sistema estiver em execução.</li>



<li>Bloqueios devem ser feitos usando primitivas do RTOS (como <code>vTaskDelay()</code>), nunca com <em>busy wait</em>.</li>
</ul>



<h3 class="wp-block-heading"><strong>Criação de tarefas com <code>xTaskCreate()</code></strong></h3>



<p class="wp-block-paragraph">A API clássica para criação dinâmica de tarefas no FreeRTOS é a função <code>xTaskCreate()</code>:</p>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>BaseType_t xTaskCreate(
    TaskFunction_t pxTaskCode,
    const char * const pcName,
    const uint16_t usStackDepth,
    void * const pvParameters,
    UBaseType_t uxPriority,
    TaskHandle_t * const pxCreatedTask
);
</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff" tabindex="0"><code><span class="line"><span style="color: #D8DEE9">BaseType_t</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">xTaskCreate</span><span style="color: #D8DEE9FF">(</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #D8DEE9">TaskFunction_t</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">pxTaskCode</span><span style="color: #ECEFF4">,</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #D8DEE9">const</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">char</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">*</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">const</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">pcName</span><span style="color: #ECEFF4">,</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #D8DEE9">const</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">uint16_t</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">usStackDepth</span><span style="color: #ECEFF4">,</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">*</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">const</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">pvParameters</span><span style="color: #ECEFF4">,</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #D8DEE9">UBaseType_t</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">uxPriority</span><span style="color: #ECEFF4">,</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #D8DEE9">TaskHandle_t</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">*</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">const</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">pxCreatedTask</span></span>
<span class="line"><span style="color: #D8DEE9FF">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span></code></pre></div>



<p class="wp-block-paragraph">Vamos detalhar cada parâmetro com precisão técnica:</p>



<ul class="wp-block-list">
<li><strong><code>pxTaskCode</code></strong><br>Ponteiro para a função que implementa a tarefa.</li>



<li><strong><code>pcName</code></strong><br>Nome simbólico da tarefa. Útil para debug, <em>trace</em> e ferramentas como FreeRTOS+Trace.</li>



<li><strong><code>usStackDepth</code></strong><br>Tamanho da pilha da tarefa <strong>em palavras</strong>, não em bytes.<br>Em arquiteturas 32 bits (como Cortex-M), 1 palavra = 4 bytes.</li>



<li><strong><code>pvParameters</code></strong><br>Ponteiro genérico para dados passados à tarefa.</li>



<li><strong><code>uxPriority</code></strong><br>Prioridade da tarefa. Quanto maior o valor, maior a prioridade.</li>



<li><strong><code>pxCreatedTask</code></strong><br>Retorna um <em>handle</em> da tarefa criada, usado para controle posterior (suspender, deletar, notificar etc.).</li>
</ul>



<h3 class="wp-block-heading"><strong>Exemplo prático: tarefa de LED</strong></h3>



<div class="wp-block-kevinbatdorf-code-block-pro" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span style="display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff"><svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg></span><span role="button" tabindex="0" style="color:#d8dee9ff;display:none" aria-label="Copy" class="code-block-pro-copy-button"><pre class="code-block-pro-copy-button-pre" aria-hidden="true"><textarea class="code-block-pro-copy-button-textarea" tabindex="-1" aria-hidden="true" readonly>#include "FreeRTOS.h"
#include "task.h"

void vTaskBlink(void *pvParameters)
{
    (void) pvParameters;

    for (;;)
    {
        HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
        vTaskDelay(pdMS_TO_TICKS(500));
    }
}

void app_main(void)
{
    xTaskCreate(
        vTaskBlink,
        "Blink",
        128,
        NULL,
        1,
        NULL
    );

    vTaskStartScheduler();
}
</textarea></pre><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg></span><pre class="shiki nord" style="background-color: #2e3440ff" tabindex="0"><code><span class="line"><span style="color: #D8DEE9FF">#</span><span style="color: #D8DEE9">include</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">FreeRTOS.h</span><span style="color: #ECEFF4">&quot;</span></span>
<span class="line"><span style="color: #D8DEE9FF">#</span><span style="color: #D8DEE9">include</span><span style="color: #D8DEE9FF"> </span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">task.h</span><span style="color: #ECEFF4">&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">vTaskBlink</span><span style="color: #D8DEE9FF">(</span><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #81A1C1">*</span><span style="color: #D8DEE9">pvParameters</span><span style="color: #D8DEE9FF">)</span></span>
<span class="line"><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF">    (</span><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF">) </span><span style="color: #D8DEE9">pvParameters</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #81A1C1">for</span><span style="color: #D8DEE9FF"> (</span><span style="color: #81A1C1">;;</span><span style="color: #D8DEE9FF">)</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF">        </span><span style="color: #88C0D0">HAL_GPIO_TogglePin</span><span style="color: #D8DEE9FF">(</span><span style="color: #D8DEE9">GPIOC</span><span style="color: #ECEFF4">,</span><span style="color: #D8DEE9FF"> </span><span style="color: #D8DEE9">GPIO_PIN_13</span><span style="color: #D8DEE9FF">)</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF">        </span><span style="color: #88C0D0">vTaskDelay</span><span style="color: #D8DEE9FF">(</span><span style="color: #88C0D0">pdMS_TO_TICKS</span><span style="color: #D8DEE9FF">(</span><span style="color: #B48EAD">500</span><span style="color: #D8DEE9FF">))</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #ECEFF4">}</span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF"> </span><span style="color: #88C0D0">app_main</span><span style="color: #D8DEE9FF">(</span><span style="color: #81A1C1">void</span><span style="color: #D8DEE9FF">)</span></span>
<span class="line"><span style="color: #ECEFF4">{</span></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #88C0D0">xTaskCreate</span><span style="color: #D8DEE9FF">(</span></span>
<span class="line"><span style="color: #D8DEE9FF">        </span><span style="color: #D8DEE9">vTaskBlink</span><span style="color: #ECEFF4">,</span></span>
<span class="line"><span style="color: #D8DEE9FF">        </span><span style="color: #ECEFF4">&quot;</span><span style="color: #A3BE8C">Blink</span><span style="color: #ECEFF4">&quot;</span><span style="color: #ECEFF4">,</span></span>
<span class="line"><span style="color: #D8DEE9FF">        </span><span style="color: #B48EAD">128</span><span style="color: #ECEFF4">,</span></span>
<span class="line"><span style="color: #D8DEE9FF">        </span><span style="color: #D8DEE9">NULL</span><span style="color: #ECEFF4">,</span></span>
<span class="line"><span style="color: #D8DEE9FF">        </span><span style="color: #B48EAD">1</span><span style="color: #ECEFF4">,</span></span>
<span class="line"><span style="color: #D8DEE9FF">        </span><span style="color: #D8DEE9">NULL</span></span>
<span class="line"><span style="color: #D8DEE9FF">    )</span><span style="color: #81A1C1">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D8DEE9FF">    </span><span style="color: #88C0D0">vTaskStartScheduler</span><span style="color: #D8DEE9FF">()</span><span style="color: #81A1C1">;</span></span>
<span class="line"><span style="color: #ECEFF4">}</span></span>
<span class="line"></span></code></pre></div>



<p class="wp-block-paragraph">Nesse exemplo:</p>



<ul class="wp-block-list">
<li>A tarefa <code>vTaskBlink</code> executa periodicamente a cada 500 ms.</li>



<li><code>vTaskDelay()</code> coloca a tarefa no estado <strong>Blocked</strong>, liberando a CPU para outras tarefas.</li>



<li><code>pdMS_TO_TICKS()</code> converte tempo em milissegundos para <em>ticks</em> do sistema, respeitando <code>configTICK_RATE_HZ</code>.</li>
</ul>



<h3 class="wp-block-heading"><strong>Estados de uma tarefa no FreeRTOS</strong></h3>



<p class="wp-block-paragraph">Internamente, o kernel gerencia cada tarefa em um dos seguintes estados principais:</p>



<ul class="wp-block-list">
<li><strong>Running</strong> – tarefa atualmente em execução.</li>



<li><strong>Ready</strong> – pronta para executar, aguardando CPU.</li>



<li><strong>Blocked</strong> – aguardando tempo, evento ou recurso.</li>



<li><strong>Suspended</strong> – explicitamente suspensa pelo usuário.</li>



<li><strong>Deleted</strong> – removida do sistema.</li>
</ul>



<p class="wp-block-paragraph">A criação correta das tarefas e o uso adequado de delays e sincronização é o que garante previsibilidade temporal, baixo consumo de CPU e bom comportamento em sistemas embarcados complexos.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p class="wp-block-paragraph">Perfeito, vamos avançar mantendo o mesmo rigor técnico e didático.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/><p>The post <a href="https://mcu.tec.br/rtos/como-criar-tarefas-e-soft-timers-no-freertos-guia-pratico-e-didatico-para-sistemas-embarcados/">Como Criar Tarefas e Soft Timers no FreeRTOS: Guia Prático e Didático para Sistemas Embarcados</a> first appeared on <a href="https://mcu.tec.br">MCU & FPGA</a>.</p>]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1016</post-id>	</item>
	</channel>
</rss>
