<?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>Welcome to Hang&#039;s Website!</title>
	<atom:link href="https://hangpersonal.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://hangpersonal.com</link>
	<description>Embedded Systems</description>
	<lastBuildDate>Tue, 28 Jul 2026 16:10:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.2</generator>

<image>
	<url>https://hangpersonal.com/wp-content/uploads/2024/10/cropped-HC-32x32.jpg</url>
	<title>Welcome to Hang&#039;s Website!</title>
	<link>https://hangpersonal.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">252449636</site>	<item>
		<title>STM32 FreeRTOS: Heap Management</title>
		<link>https://hangpersonal.com/2026/07/28/stm32-freertos-heap/</link>
		
		<dc:creator><![CDATA[hangcui1201]]></dc:creator>
		<pubDate>Tue, 28 Jul 2026 15:52:12 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://hangpersonal.com/?p=7927</guid>

					<description><![CDATA[STM32 Microcontroller and FreeRTOS Development Back to top of the page]]></description>
										<content:encoded><![CDATA[
<a href="https://hangpersonal.com/embedded-system/stm32-mcu/freertos-tutorials/" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
STM32 Microcontroller and FreeRTOS Development
</a>
<br><br>



<br><br>
<a href="#top" style="font-size:20px; color: blue;">Back to top of the page</a>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">7927</post-id>	</item>
		<item>
		<title>STM32 FreeRTOS: Hook Functions and Tickless Idle</title>
		<link>https://hangpersonal.com/2026/07/27/stm32-freertos-hook-tickless/</link>
		
		<dc:creator><![CDATA[hangcui1201]]></dc:creator>
		<pubDate>Mon, 27 Jul 2026 20:27:08 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://hangpersonal.com/?p=7896</guid>

					<description><![CDATA[STM32 Microcontroller and FreeRTOS Development vApplicationIdleHook() The idle task hook is a user-defined callback function that FreeRTOS executes repeatedly whenever no other task is ready to run. It is implemented as vApplicationIdleHook() and enabled by setting configUSE_IDLE_HOOK to 1 in FreeRTOSConfig.h. The hook can be used for low-priority background operations, such as entering a low-power...]]></description>
										<content:encoded><![CDATA[
<a href="https://hangpersonal.com/embedded-system/stm32-mcu/freertos-tutorials/" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
STM32 Microcontroller and FreeRTOS Development
</a>
<br><br>



<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


            <div  class="spbtbl-wrapper spbtbl-blockmode spbtbl-fullwidth" >
                                <table class="spbtbl-style spbtbl-color-blue" title="FreeRTOS: Hook Functions and Tickless Idle"  itemscope itemtype="http://schema.org/Table" >
                    <!-- Superb Tables Plugin -->
                    <thead>
                        <tr>
                            <th style="font-size: 18px !important;"  itemprop="name"  align="left">Hook API Function</th><th style="font-size: 18px !important;"  itemprop="name"  align="left">Description</th>                        </tr>
                    </thead>
                    <tbody>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#task_idle_hook" style="font-size: 20px;color: blue">vApplicationIdleHook()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Runs user-defined background or low-power code during Idle task execution</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#application_tick" style="font-size: 20px;color: blue">vApplicationTickHook()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Runs from the RTOS tick interrupt</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#application_malloc_fail" style="font-size: 20px;color: blue">vApplicationMallocFailedHook()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Called when pvPortMalloc() cannot allocate memory</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#application_stack_overflow" style="font-size: 20px;color: blue">vApplicationStackOverflowHook()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Called when a task stack overflow is detected</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#application_daemon_task_startup" style="font-size: 20px;color: blue">vApplicationDaemonTaskStartupHook()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Runs once when the Timer Service/Daemon task starts</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#tickless_idle" style="font-size: 20px;color: blue">configUSE_TICKLESS_IDLE</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Enables tickless idle mode, allowing FreeRTOS to suppress unnecessary tick interrupts and reduce power consumption while the system is idle</td>                            </tr>
                                            </tbody>
                </table>
                            </div>




<div class="article-text" style="margin-top:20px; margin-bottom:30px;">

<b id="task_idle_hook" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
vApplicationIdleHook()
</b>

<p>
The idle task hook is a user-defined callback function that FreeRTOS executes repeatedly whenever no other task is ready to run. It is implemented as <span class="highlight">vApplicationIdleHook()</span> and enabled by setting <span class="highlight">configUSE_IDLE_HOOK</span> to 1 in <span class="highlight">FreeRTOSConfig.h</span>. The hook can be used for low-priority background operations, such as entering a low-power mode, collecting system statistics, or performing simple maintenance tasks. It must never block, call functions that may block, or perform lengthy processing, because doing so prevents the idle task from running normally and may delay the cleanup of deleted tasks.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 vApplicationIdleHook(void)

// ---------------------- Example ----------------------

#define configUSE_TICKLESS_IDLE    0  
#define configUSE_IDLE_HOOK        1
#define configIDLE_SHOULD_YIELD    1 

void BeforeEnterSleep(void)
{
    __HAL_RCC_GPIOB_CLK_SLEEP_DISABLE();
    __HAL_RCC_GPIOC_CLK_SLEEP_DISABLE();
    __HAL_RCC_GPIOD_CLK_SLEEP_DISABLE();
    __HAL_RCC_GPIOE_CLK_SLEEP_DISABLE();
    __HAL_RCC_GPIOF_CLK_SLEEP_DISABLE();
    __HAL_RCC_GPIOG_CLK_SLEEP_DISABLE();
    __HAL_RCC_GPIOH_CLK_SLEEP_DISABLE();
}

void AfterExitSleep(void)
{
    __HAL_RCC_GPIOB_CLK_SLEEP_ENABLE();
    __HAL_RCC_GPIOC_CLK_SLEEP_ENABLE();
    __HAL_RCC_GPIOD_CLK_SLEEP_ENABLE();
    __HAL_RCC_GPIOE_CLK_SLEEP_ENABLE();
    __HAL_RCC_GPIOF_CLK_SLEEP_ENABLE();
    __HAL_RCC_GPIOG_CLK_SLEEP_ENABLE();
    __HAL_RCC_GPIOH_CLK_SLEEP_ENABLE();
}

void vApplicationIdleHook(void)
{
    BeforeEnterSleep();
    __DSB();  
    __WFI();  
    __ISB();  
    AfterExitSleep();
}</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">vApplicationIdleHook</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configUSE_TICKLESS_IDLE</span><span style="color: #D5CED9">    </span><span style="color: #F39C12">0</span><span style="color: #D5CED9">  </span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configUSE_IDLE_HOOK</span><span style="color: #D5CED9">        </span><span style="color: #F39C12">1</span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configIDLE_SHOULD_YIELD</span><span style="color: #D5CED9">    </span><span style="color: #F39C12">1</span><span style="color: #D5CED9"> </span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">BeforeEnterSleep</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">{</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOB_CLK_SLEEP_DISABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOC_CLK_SLEEP_DISABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOD_CLK_SLEEP_DISABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOE_CLK_SLEEP_DISABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOF_CLK_SLEEP_DISABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOG_CLK_SLEEP_DISABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOH_CLK_SLEEP_DISABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">}</span></span>
<span class="line"></span>
<span class="line cbp-see-more-line "><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">AfterExitSleep</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">{</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOB_CLK_SLEEP_ENABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOC_CLK_SLEEP_ENABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOD_CLK_SLEEP_ENABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOE_CLK_SLEEP_ENABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOF_CLK_SLEEP_ENABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOG_CLK_SLEEP_ENABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOH_CLK_SLEEP_ENABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">vApplicationIdleHook</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">{</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">BeforeEnterSleep</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__DSB</span><span style="color: #D5CED9">();  </span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__WFI</span><span style="color: #D5CED9">();  </span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__ISB</span><span style="color: #D5CED9">();  </span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">AfterExitSleep</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">}</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="application_tick" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
vApplicationTickHook()
</b>

<p>
<span class="highlight">vApplicationTickHook()</span> is a user-defined FreeRTOS hook function that is called from the RTOS tick interrupt each time the system tick occurs. To enable it, set <span class="highlight">configUSE_TICK_HOOK</span> to 1 in <span class="highlight">FreeRTOSConfig.h</span>. It is typically used for short, periodic operations such as incrementing counters, updating software timing variables, or triggering lightweight monitoring functions. Because it executes in interrupt context, the hook must run quickly, must not block, and may only call FreeRTOS API functions that are safe to use from an ISR.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 vApplicationTickHook(void)

// ---------------------- Example ----------------------

#define configUSE_TICK_HOOK    1

volatile uint32_t ulTickHookCounter = 0;
volatile BaseType_t xOneSecondElapsed = pdFALSE;

void vApplicationTickHook(void) {
    ulTickHookCounter++;

    // Set a flag approximately once every second
    if (ulTickHookCounter >= configTICK_RATE_HZ)
    {
        ulTickHookCounter = 0;
        xOneSecondElapsed = pdTRUE;
    }
}</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">vApplicationTickHook</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configUSE_TICK_HOOK</span><span style="color: #D5CED9">    </span><span style="color: #F39C12">1</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">volatile</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> ulTickHookCounter </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #F39C12">0</span><span style="color: #D5CED9">;</span></span>
<span class="line"><span style="color: #C74DED">volatile</span><span style="color: #D5CED9"> BaseType_t xOneSecondElapsed </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> pdFALSE;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">vApplicationTickHook</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">) {</span></span>
<span class="line"><span style="color: #D5CED9">    ulTickHookCounter</span><span style="color: #EE5D43">++</span><span style="color: #D5CED9">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #A0A1A7CC">// Set a flag approximately once every second</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #C74DED">if</span><span style="color: #D5CED9"> (ulTickHookCounter </span><span style="color: #EE5D43">&gt;=</span><span style="color: #D5CED9"> configTICK_RATE_HZ)</span></span>
<span class="line"><span style="color: #D5CED9">    {</span></span>
<span class="line"><span style="color: #D5CED9">        ulTickHookCounter </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #F39C12">0</span><span style="color: #D5CED9">;</span></span>
<span class="line"><span style="color: #D5CED9">        xOneSecondElapsed </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> pdTRUE;</span></span>
<span class="line"><span style="color: #D5CED9">    }</span></span>
<span class="line"><span style="color: #D5CED9">}</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="application_malloc_fail" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
vApplicationMallocFailedHook()
</b>

<p>
<span class="highlight">vApplicationMallocFailedHook()</span> is a user-defined FreeRTOS hook function that is called whenever a dynamic memory allocation request fails, such as when <span class="highlight">pvPortMalloc()</span>, <span class="highlight">xTaskCreate()</span>, or another kernel object creation function cannot obtain enough heap memory. To enable it, set <span class="highlight">configUSE_MALLOC_FAILED_HOOK</span> to 1 in <span class="highlight">FreeRTOSConfig.h</span>. The hook is commonly used to record diagnostic information, trigger an assertion, illuminate an error indicator, or halt execution for debugging. Because the system may have very little memory remaining, the hook should avoid performing additional dynamic memory allocations.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 vApplicationMallocFailedHook(void)

// ---------------------- Example ----------------------

#define configUSE_MALLOC_FAILED_HOOK    1

void vApplicationMallocFailedHook(void) 
{
    taskDISABLE_INTERRUPTS();
    for (;;) {}
}</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">vApplicationMallocFailedHook</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configUSE_MALLOC_FAILED_HOOK</span><span style="color: #D5CED9">    </span><span style="color: #F39C12">1</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">vApplicationMallocFailedHook</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">) </span></span>
<span class="line"><span style="color: #D5CED9">{</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">taskDISABLE_INTERRUPTS</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #C74DED">for</span><span style="color: #D5CED9"> (;;) {}</span></span>
<span class="line"><span style="color: #D5CED9">}</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="application_stack_overflow" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
vApplicationStackOverflowHook()
</b>

<p>
<span class="highlight">vApplicationStackOverflowHook()</span> is a user-defined FreeRTOS hook function that is called when the kernel detects that a task has exceeded its allocated stack space. To enable stack-overflow checking, set <span class="highlight">configCHECK_FOR_STACK_OVERFLOW</span> to 1 or 2 in <span class="highlight">FreeRTOSConfig.h</span>, with 2 providing more thorough checking. The hook receives the handle and name of the affected task, allowing the application to record diagnostic information, trigger an assertion, illuminate an error LED, or halt execution for debugging. Because stack corruption may already have occurred, the hook should avoid complex operations and should normally stop the system so the cause can be investigated.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 vApplicationStackOverflowHook(TaskHandle_t xTask, 
                                   char *pcTaskName)

// ---------------------- Example ----------------------

#define INCLUDE_uxTaskGetStackHighWaterMark    1
#define configCHECK_FOR_STACK_OVERFLOW			   2    

volatile const char *g_overflow_task_name = NULL;
volatile TaskHandle_t g_overflow_task_handle = NULL;

void vApplicationStackOverflowHook(TaskHandle_t xTask, 
                                   char *pcTaskName) 
{
    g_overflow_task_handle = xTask;
    g_overflow_task_name = pcTaskName; // points to the task name string

    taskDISABLE_INTERRUPTS();
    for (;;) {
        __NOP(); // set breakpoint here and inspect g_overflow_task_name
                 // LED may also be turned on or toggled here
    }
}

TaskHandle_t taskHandler;
UBaseType_t uxRemainingWords;
uxRemainingWords = uxTaskGetStackHighWaterMark(taskHandler);
printf("Unused stack: %lu words (%lu bytes)\r\n",
       (unsigned long)uxRemainingWords,
       (unsigned long)uxRemainingWords * sizeof(StackType_t));</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">vApplicationStackOverflowHook</span><span style="color: #D5CED9">(TaskHandle_t </span><span style="color: #00E8C6">xTask</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                                   </span><span style="color: #C74DED">char</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #00E8C6">pcTaskName</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">INCLUDE_uxTaskGetStackHighWaterMark</span><span style="color: #D5CED9">    </span><span style="color: #F39C12">1</span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configCHECK_FOR_STACK_OVERFLOW</span><span style="color: #D5CED9">			   </span><span style="color: #F39C12">2</span><span style="color: #D5CED9">    </span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">volatile</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">char</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9">g_overflow_task_name </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">NULL</span><span style="color: #D5CED9">;</span></span>
<span class="line"><span style="color: #C74DED">volatile</span><span style="color: #D5CED9"> TaskHandle_t g_overflow_task_handle </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">NULL</span><span style="color: #D5CED9">;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">vApplicationStackOverflowHook</span><span style="color: #D5CED9">(TaskHandle_t </span><span style="color: #00E8C6">xTask</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                                   </span><span style="color: #C74DED">char</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #00E8C6">pcTaskName</span><span style="color: #D5CED9">) </span></span>
<span class="line"><span style="color: #D5CED9">{</span></span>
<span class="line"><span style="color: #D5CED9">    g_overflow_task_handle </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> xTask;</span></span>
<span class="line"><span style="color: #D5CED9">    g_overflow_task_name </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> pcTaskName;</span><span style="color: #A0A1A7CC"> // points to the task name string</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">taskDISABLE_INTERRUPTS</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #C74DED">for</span><span style="color: #D5CED9"> (;;) {</span></span>
<span class="line cbp-see-more-line "><span style="color: #D5CED9">        </span><span style="color: #FFE66D">__NOP</span><span style="color: #D5CED9">();</span><span style="color: #A0A1A7CC"> // set breakpoint here and inspect g_overflow_task_name</span></span>
<span class="line"><span style="color: #D5CED9">                 </span><span style="color: #A0A1A7CC">// LED may also be turned on or toggled here</span></span>
<span class="line"><span style="color: #D5CED9">    }</span></span>
<span class="line"><span style="color: #D5CED9">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">TaskHandle_t taskHandler;</span></span>
<span class="line"><span style="color: #D5CED9">UBaseType_t uxRemainingWords;</span></span>
<span class="line"><span style="color: #D5CED9">uxRemainingWords </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">uxTaskGetStackHighWaterMark</span><span style="color: #D5CED9">(taskHandler);</span></span>
<span class="line"><span style="color: #FFE66D">printf</span><span style="color: #D5CED9">(</span><span style="color: #96E072">&quot;Unused stack: </span><span style="color: #EE5D43">%lu</span><span style="color: #96E072"> words (</span><span style="color: #EE5D43">%lu</span><span style="color: #96E072"> bytes)</span><span style="color: #EE5D43">\r\n</span><span style="color: #96E072">&quot;</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">       (</span><span style="color: #C74DED">unsigned</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">long</span><span style="color: #D5CED9">)</span><span style="color: #00E8C6">uxRemainingWords</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">       (</span><span style="color: #C74DED">unsigned</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">long</span><span style="color: #D5CED9">)uxRemainingWords </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">sizeof</span><span style="color: #D5CED9">(StackType_t));</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="application_daemon_task_startup" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
vApplicationDaemonTaskStartupHook()
</b>

<p>
<span class="highlight">vApplicationDaemonTaskStartupHook()</span> is a user-defined FreeRTOS hook function that is called once when the daemon task, also known as the timer service task, begins running after the scheduler starts. To enable it, set <span class="highlight">configUSE_DAEMON_TASK_STARTUP_HOOK</span> to 1 in <span class="highlight">FreeRTOSConfig.h</span>. It is typically used to perform application initialization that must occur after the scheduler is active, such as creating synchronization objects, starting software timers, or initializing components that depend on FreeRTOS services. Because the hook executes in the context of the daemon task, lengthy or blocking operations should be avoided so that software timers and deferred callback processing are not delayed.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 vApplicationDaemonTaskStartupHook(void)

// ---------------------- Example ----------------------

#define configUSE_DAEMON_TASK_STARTUP_HOOK    1
#define configUSE_TIMERS				              1

TimerHandle_t OneShotTimer_Handle;

OneShotTimer_Handle = 
  xTimerCreate((const char*			       ) "OneShotTimer",
			         (TickType_t			       ) 3000,
							 (UBaseType_t			       ) pdFALSE,
							 (void*				           ) 1,
							 (TimerCallbackFunction_t) OneShotTimerCallback);

void vApplicationDaemonTaskStartupHook(void) {
    BaseType_t xResult;
    xResult = xTimerStart(OneShotTimer_Handle, 0);
    configASSERT(xResult == pdPASS);
}

void OneShotTimerCallback(TimerHandle_t xTimer) {
	static TickType_t xTimeNow;
	xTimeNow = xTaskGetTickCount();
	printf("One-shot timer callback executing: %d\r\n", (int)xTimeNow);
}</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">vApplicationDaemonTaskStartupHook</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configUSE_DAEMON_TASK_STARTUP_HOOK</span><span style="color: #D5CED9">    </span><span style="color: #F39C12">1</span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configUSE_TIMERS</span><span style="color: #D5CED9">				              </span><span style="color: #F39C12">1</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">TimerHandle_t OneShotTimer_Handle;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">OneShotTimer_Handle </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span></span>
<span class="line"><span style="color: #D5CED9">  </span><span style="color: #FFE66D">xTimerCreate</span><span style="color: #D5CED9">((</span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">char</span><span style="color: #EE5D43">*</span><span style="color: #D5CED9">			       ) </span><span style="color: #96E072">&quot;OneShotTimer&quot;</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">			         (TickType_t			       ) </span><span style="color: #F39C12">3000</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">							 (UBaseType_t			       ) </span><span style="color: #00E8C6">pdFALSE</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">							 (</span><span style="color: #C74DED">void</span><span style="color: #EE5D43">*</span><span style="color: #D5CED9">				           ) </span><span style="color: #F39C12">1</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">							 (TimerCallbackFunction_t) </span><span style="color: #00E8C6">OneShotTimerCallback</span><span style="color: #D5CED9">);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">vApplicationDaemonTaskStartupHook</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">) {</span></span>
<span class="line"><span style="color: #D5CED9">    BaseType_t xResult;</span></span>
<span class="line"><span style="color: #D5CED9">    xResult </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xTimerStart</span><span style="color: #D5CED9">(OneShotTimer_Handle, </span><span style="color: #F39C12">0</span><span style="color: #D5CED9">);</span></span>
<span class="line cbp-see-more-line "><span style="color: #D5CED9">    </span><span style="color: #FFE66D">configASSERT</span><span style="color: #D5CED9">(xResult </span><span style="color: #EE5D43">==</span><span style="color: #D5CED9"> pdPASS);</span></span>
<span class="line"><span style="color: #D5CED9">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">OneShotTimerCallback</span><span style="color: #D5CED9">(TimerHandle_t </span><span style="color: #00E8C6">xTimer</span><span style="color: #D5CED9">) {</span></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #C74DED">static</span><span style="color: #D5CED9"> TickType_t xTimeNow;</span></span>
<span class="line"><span style="color: #D5CED9">	xTimeNow </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xTaskGetTickCount</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #FFE66D">printf</span><span style="color: #D5CED9">(</span><span style="color: #96E072">&quot;One-shot timer callback executing: </span><span style="color: #EE5D43">%d\r\n</span><span style="color: #96E072">&quot;</span><span style="color: #D5CED9">, (</span><span style="color: #C74DED">int</span><span style="color: #D5CED9">)xTimeNow);</span></span>
<span class="line"><span style="color: #D5CED9">}</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="tickless_idle" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
configUSE_TICKLESS_IDLE
</b>

<p>
<span class="highlight">configUSE_TICKLESS_IDLE</span> enables FreeRTOS tickless idle mode, which reduces power consumption when no application task is ready to run. Normally, the periodic RTOS tick interrupt continues waking the processor even while the Idle task is running. When tickless idle is enabled, FreeRTOS temporarily stops the tick interrupt, places the processor into a low-power state, and sleeps until an interrupt occurs or a blocked task is due to wake. After waking, the kernel adjusts its tick count to account for the elapsed time. Set it to 0 to disable tickless idle, 1 to use the port&#8217;s built-in implementation when supported, or 2 to provide a custom <span class="highlight">portSUPPRESS_TICKS_AND_SLEEP()</span> implementation.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>#define configUSE_TICKLESS_IDLE    1                       

// FreeRTOSConfig.h
extern void PreSleepProcessing(uint32_t ulExpectedIdleTime);
extern void PostSleepProcessing(uint32_t ulExpectedIdleTime);
#define configPRE_SLEEP_PROCESSING  PreSleepProcessing	 
#define configPOST_SLEEP_PROCESSING  PostSleepProcessing	 

// main.c
void PreSleepProcessing(uint32_t ulExpectedIdleTime)
{
    (void)ulExpectedIdleTime;

    // Disable GPIO clocks that are not needed during sleep
    __HAL_RCC_GPIOB_CLK_DISABLE();
    __HAL_RCC_GPIOC_CLK_DISABLE();
    __HAL_RCC_GPIOD_CLK_DISABLE();
    __HAL_RCC_GPIOE_CLK_DISABLE();
    __HAL_RCC_GPIOF_CLK_DISABLE();
    __HAL_RCC_GPIOG_CLK_DISABLE();
    __HAL_RCC_GPIOH_CLK_DISABLE();
}

void PostSleepProcessing(uint32_t ulExpectedIdleTime)
{
    (void)ulExpectedIdleTime;

    // Re-enable GPIO clocks after waking up
    __HAL_RCC_GPIOB_CLK_ENABLE();
    __HAL_RCC_GPIOC_CLK_ENABLE();
    __HAL_RCC_GPIOD_CLK_ENABLE();
    __HAL_RCC_GPIOE_CLK_ENABLE();
    __HAL_RCC_GPIOF_CLK_ENABLE();
    __HAL_RCC_GPIOG_CLK_ENABLE();
    __HAL_RCC_GPIOH_CLK_ENABLE();
}</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configUSE_TICKLESS_IDLE</span><span style="color: #D5CED9">    </span><span style="color: #F39C12">1</span><span style="color: #D5CED9">                       </span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// FreeRTOSConfig.h</span></span>
<span class="line"><span style="color: #C74DED">extern</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">PreSleepProcessing</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">ulExpectedIdleTime</span><span style="color: #D5CED9">);</span></span>
<span class="line"><span style="color: #C74DED">extern</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">PostSleepProcessing</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">ulExpectedIdleTime</span><span style="color: #D5CED9">);</span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configPRE_SLEEP_PROCESSING</span><span style="color: #D5CED9">  PreSleepProcessing	 </span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configPOST_SLEEP_PROCESSING</span><span style="color: #D5CED9">  PostSleepProcessing	 </span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// main.c</span></span>
<span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">PreSleepProcessing</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">ulExpectedIdleTime</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">{</span></span>
<span class="line"><span style="color: #D5CED9">    (</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">)ulExpectedIdleTime;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #A0A1A7CC">// Disable GPIO clocks that are not needed during sleep</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOB_CLK_DISABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOC_CLK_DISABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOD_CLK_DISABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOE_CLK_DISABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOF_CLK_DISABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line cbp-see-more-line "><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOG_CLK_DISABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOH_CLK_DISABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">PostSleepProcessing</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">ulExpectedIdleTime</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">{</span></span>
<span class="line"><span style="color: #D5CED9">    (</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">)ulExpectedIdleTime;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #A0A1A7CC">// Re-enable GPIO clocks after waking up</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOB_CLK_ENABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOC_CLK_ENABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOD_CLK_ENABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOE_CLK_ENABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOF_CLK_ENABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOG_CLK_ENABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">__HAL_RCC_GPIOH_CLK_ENABLE</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #D5CED9">}</span></span></code></pre></div>



<br><br>
<a href="#top" style="font-size:20px; color: blue;">Back to top of the page</a>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">7896</post-id>	</item>
		<item>
		<title>STM32 FreeRTOS: Task Notifications</title>
		<link>https://hangpersonal.com/2026/07/22/stm32-freertos-task-notification/</link>
		
		<dc:creator><![CDATA[hangcui1201]]></dc:creator>
		<pubDate>Wed, 22 Jul 2026 23:55:35 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://hangpersonal.com/?p=7813</guid>

					<description><![CDATA[STM32 Microcontroller and FreeRTOS Development Task notifications enable direct communication between tasks without requiring separate kernel objects such as queues, semaphores, or event groups. Pending: When a task receives a notification, its notification state is set to pending. Not pending: When the task processes the notification, its notification state is cleared to not pending. Advantages:...]]></description>
										<content:encoded><![CDATA[
<a href="https://hangpersonal.com/embedded-system/stm32-mcu/freertos-tutorials/" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
STM32 Microcontroller and FreeRTOS Development
</a>
<br><br>



<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


            <div  class="spbtbl-wrapper spbtbl-blockmode" >
                                <table class="spbtbl-style spbtbl-color-blue" title="FreeRTOS: Task Notification"  itemscope itemtype="http://schema.org/Table" >
                    <!-- Superb Tables Plugin -->
                    <thead>
                        <tr>
                            <th style="font-size: 18px !important;"  itemprop="name"  align="left">Task Notification API Function</th><th style="font-size: 18px !important;"  itemprop="name"  align="left">Description</th>                        </tr>
                    </thead>
                    <tbody>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#task_notify" style="font-size: 20px;color: blue">xTaskNotify()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Sends a notification to a task and updates its notification value using the specified action</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#task_notify_from_isr" style="font-size: 20px;color: blue">xTaskNotifyFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Sends a task notification safely from an ISR</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#task_notify_give" style="font-size: 20px;color: blue">xTaskNotifyGive()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Increments a task's notification value and unblocks it if waiting</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#task_notify_give_from_isr" style="font-size: 20px;color: blue">vTaskNotifyGiveFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Increments a task’s notification value from an ISR</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#task_notify_query" style="font-size: 20px;color: blue">xTaskNotifyAndQuery()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Sends a notification and returns the task’s previous notification value</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#task_notify_query_from_isr" style="font-size: 20px;color: blue">xTaskNotifyAndQueryFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Performs notify-and-query safely from an ISR</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#task_notify_take" style="font-size: 20px;color: blue">ulTaskNotifyTake()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Waits for a notification count, then clears or decrements it</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#task_notify_wait" style="font-size: 20px;color: blue">xTaskNotifyWait()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Waits for a notification and optionally clears selected notification bits</td>                            </tr>
                                            </tbody>
                </table>
                            </div>




<div class="article-text" style="margin-top:20px; margin-bottom:30px;">

<p>
Task notifications enable direct communication between tasks without requiring separate kernel objects such as queues, semaphores, or event groups.
</p>

<ul>
<li> Pending: When a task receives a notification, its notification state is set to pending.
</li> 
<li> Not pending: When the task processes the notification, its notification state is cleared to not pending.
</li>
</ul>

<p></p>

<p>
<b>Advantages</b>: Faster than using queues, semaphore and event groups to perform an equivalent operation. Requires significantly less RAM than using a queue, semaphore or an event group.
</p>

<p>
<b>Limitations</b>: Unlike queues, semaphores and event groups, task notifications cannot be used to send events or data from a task to an ISR, although they can be used to send events or data from an ISR to a task. Unlike queues, semaphores and event groups, task notifications cannot be sent to multiple tasks.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>// FreeRTOSConfig.h
#define configUSE_TASK_NOTIFICATIONS   1 </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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #A0A1A7CC">// FreeRTOSConfig.h</span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configUSE_TASK_NOTIFICATIONS</span><span style="color: #D5CED9">   </span><span style="color: #F39C12">1</span><span style="color: #D5CED9"> </span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="task_notify" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xTaskNotify()
</b>

<p>
<span class="highlight">xTaskNotify()</span> sends a task notification to another task and updates the receiving task&#8217;s notification value according to the selected <span class="highlight">eNotifyAction</span>. It can set specific bits, increment the value, overwrite the existing value, update it only when no unread notification is pending, or generate a notification event without modifying the value. If the receiving task is blocked waiting for the notification, it is moved to the Ready state. The function normally returns <span class="highlight">pdPASS</span>; however, when <span class="highlight">eSetValueWithoutOverwrite</span> is used, it returns <span class="highlight">pdFAIL</span> if a previous notification is still pending.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xTaskNotify(TaskHandle_t xTaskToNotify,
                       uint32_t ulValue,
                       eNotifyAction eAction)
                       
// ---------------------- Example ---------------------- 

TaskHandle_t ReceiverTask_Handler;
uint8_t keyState;
BaseType_t err;
err = xTaskNotify((TaskHandle_t	) ReceiverTask_Handler,
							    (uint32_t		  ) keyState,
							    (eNotifyAction) eSetValueWithOverwrite);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xTaskNotify</span><span style="color: #D5CED9">(TaskHandle_t </span><span style="color: #00E8C6">xTaskToNotify</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                       </span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">ulValue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                       eNotifyAction </span><span style="color: #00E8C6">eAction</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">                       </span></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ---------------------- </span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">TaskHandle_t ReceiverTask_Handler;</span></span>
<span class="line"><span style="color: #C74DED">uint8_t</span><span style="color: #D5CED9"> keyState;</span></span>
<span class="line"><span style="color: #D5CED9">BaseType_t err;</span></span>
<span class="line"><span style="color: #D5CED9">err </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xTaskNotify</span><span style="color: #D5CED9">((TaskHandle_t	) </span><span style="color: #00E8C6">ReceiverTask_Handler</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">							    (</span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9">		  ) </span><span style="color: #00E8C6">keyState</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">							    (eNotifyAction) </span><span style="color: #00E8C6">eSetValueWithOverwrite</span><span style="color: #D5CED9">);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="task_notify_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xTaskNotifyFromISR()
</b>

<p>
<span class="highlight">xTaskNotifyFromISR()</span> is the interrupt-safe version of <span class="highlight">xTaskNotify()</span>. It supports the same notification actions and includes the <span class="highlight">pxHigherPriorityTaskWoken</span> parameter, which is set to <span class="highlight">pdTRUE</span> if the notification unblocks a task with a higher priority than the currently running task. This variable must be initialized to <span class="highlight">pdFALSE</span> before the function is called. If it is set to <span class="highlight">pdTRUE</span>, <span class="highlight">portYIELD_FROM_ISR()</span> should be called before exiting the ISR to request an immediate context switch.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xTaskNotifyFromISR(TaskHandle_t xTaskToNotify, 
                              uint32_t ulValue, 
                              eNotifyAction eAction, 
                              BaseType_t * pxHigherPriorityTaskWoken)

TaskHandle_t EventGroupTask_Handler;
#define EVENTBIT_0	 (1 &lt;&lt; 0)

BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xTaskNotifyFromISR((TaskHandle_t ) EventGroupTask_Handler,
						       (uint32_t	   ) EVENTBIT_0,
						       (eNotifyAction) eSetBits,
						       (BaseType_t*	 ) &amp;xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xTaskNotifyFromISR</span><span style="color: #D5CED9">(TaskHandle_t </span><span style="color: #00E8C6">xTaskToNotify</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                              </span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">ulValue</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                              eNotifyAction </span><span style="color: #00E8C6">eAction</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                              BaseType_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxHigherPriorityTaskWoken</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">TaskHandle_t EventGroupTask_Handler;</span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">EVENTBIT_0</span><span style="color: #D5CED9">	 (</span><span style="color: #F39C12">1</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">&lt;&lt;</span><span style="color: #D5CED9"> </span><span style="color: #F39C12">0</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">BaseType_t xHigherPriorityTaskWoken </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> pdFALSE;</span></span>
<span class="line"><span style="color: #FFE66D">xTaskNotifyFromISR</span><span style="color: #D5CED9">((TaskHandle_t ) </span><span style="color: #00E8C6">EventGroupTask_Handler</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">						       (</span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9">	   ) </span><span style="color: #00E8C6">EVENTBIT_0</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">						       (eNotifyAction) </span><span style="color: #00E8C6">eSetBits</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">						       (BaseType_t</span><span style="color: #EE5D43">*</span><span style="color: #D5CED9">	 ) </span><span style="color: #EE5D43">&amp;</span><span style="color: #00E8C6">xHigherPriorityTaskWoken</span><span style="color: #D5CED9">);</span></span>
<span class="line"><span style="color: #FFE66D">portYIELD_FROM_ISR</span><span style="color: #D5CED9">(xHigherPriorityTaskWoken);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="task_notify_give" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xTaskNotifyGive()
</b>

<p>
<span class="highlight">xTaskNotifyGive()</span> increments the target task&#8217;s notification value by one and marks the notification as pending. It is equivalent to calling <span class="highlight">xTaskNotify()</span> with the <span class="highlight">eIncrement</span> action and is typically paired with <span class="highlight">ulTaskNotifyTake()</span>. Together, these functions provide a lightweight alternative to a binary or counting semaphore when an event needs to be delivered to a single specific task. <span class="highlight">xTaskNotifyGive()</span> must be called from task context; use <span class="highlight">vTaskNotifyGiveFromISR()</span> when sending the notification from an ISR.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xTaskNotifyGive(TaskHandle_t xTaskToNotify)

// ---------------------- Example ---------------------- 

TaskHandle_t SemapGiveTask_Handler;
xTaskNotifyGive(SemapTakeTask_Handler);
printf("TaskNotifyGive!\r\n");</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xTaskNotifyGive</span><span style="color: #D5CED9">(TaskHandle_t </span><span style="color: #00E8C6">xTaskToNotify</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ---------------------- </span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">TaskHandle_t SemapGiveTask_Handler;</span></span>
<span class="line"><span style="color: #FFE66D">xTaskNotifyGive</span><span style="color: #D5CED9">(SemapTakeTask_Handler);</span></span>
<span class="line"><span style="color: #FFE66D">printf</span><span style="color: #D5CED9">(</span><span style="color: #96E072">&quot;TaskNotifyGive!</span><span style="color: #EE5D43">\r\n</span><span style="color: #96E072">&quot;</span><span style="color: #D5CED9">);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="task_notify_give_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
vTaskNotifyGiveFromISR()
</b>

<p>
<span class="highlight">vTaskNotifyGiveFromISR()</span> safely increments a task&#8217;s notification value from an interrupt service routine and marks the notification as pending. It is commonly used to unblock a task responsible for deferred interrupt processing, such as handling received data or processing a completed DMA transfer. The <span class="highlight">pxHigherPriorityTaskWoken</span> parameter indicates whether the notification unblocked a task with a higher priority than the interrupted task. If it is set to <span class="highlight">pdTRUE</span>, <span class="highlight">portYIELD_FROM_ISR()</span> should be called before exiting the ISR to request an immediate context switch.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 vTaskNotifyGiveFromISR(TaskHandle_t xTaskHandle, 
                            BaseType_t * pxHigherPriorityTaskWoken)
                            
// ---------------------- Example ----------------------

TaskHandle_t DataProcess_Handler;
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
vTaskNotifyGiveFromISR(DataProcess_Handler, &amp;xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">vTaskNotifyGiveFromISR</span><span style="color: #D5CED9">(TaskHandle_t </span><span style="color: #00E8C6">xTaskHandle</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                            BaseType_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxHigherPriorityTaskWoken</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">                            </span></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">TaskHandle_t DataProcess_Handler;</span></span>
<span class="line"><span style="color: #D5CED9">BaseType_t xHigherPriorityTaskWoken </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> pdFALSE;</span></span>
<span class="line"><span style="color: #FFE66D">vTaskNotifyGiveFromISR</span><span style="color: #D5CED9">(DataProcess_Handler, </span><span style="color: #EE5D43">&amp;</span><span style="color: #00E8C6">xHigherPriorityTaskWoken</span><span style="color: #D5CED9">);</span></span>
<span class="line"><span style="color: #FFE66D">portYIELD_FROM_ISR</span><span style="color: #D5CED9">(xHigherPriorityTaskWoken);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="task_notify_query" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xTaskNotifyAndQuery()
</b>

<p>
<span class="highlight">xTaskNotifyAndQuery()</span> performs the same notification and value-update operation as <span class="highlight">xTaskNotify()</span>, while also returning the target task’s previous notification value through <span class="highlight">pulPreviousNotifyValue</span>. The previous value is captured atomically before the selected <span class="highlight">eNotifyAction</span> modifies it. This is useful when the sending task needs to inspect and update the notification value in a single operation, such as checking previously set event bits or reading a counter before incrementing or overwriting it. The function must be called from task context.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xTaskNotifyAndQuery(TaskHandle_t xTaskToNotify,
                               uint32_t ulValue,
                               eNotifyAction eAction,
                               uint32_t * pulPreviousNotificationValue)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xTaskNotifyAndQuery</span><span style="color: #D5CED9">(TaskHandle_t </span><span style="color: #00E8C6">xTaskToNotify</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                               </span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">ulValue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                               eNotifyAction </span><span style="color: #00E8C6">eAction</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                               </span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pulPreviousNotificationValue</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="task_notify_query_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xTaskNotifyAndQueryFromISR()
</b>

<p>
<span class="highlight">xTaskNotifyAndQueryFromISR()</span> is the interrupt-safe version of <span class="highlight">xTaskNotifyAndQuery()</span>. It sends a notification to the target task, updates its notification value according to the selected <span class="highlight">eNotifyAction</span>, and returns the value that existed before the update through <span class="highlight">pulPreviousNotifyValue</span>. The <span class="highlight">pxHigherPriorityTaskWoken</span> parameter indicates whether the notification unblocked a higher-priority task, allowing the ISR to request an immediate context switch with <span class="highlight">portYIELD_FROM_ISR()</span>. The function normally returns <span class="highlight">pdPASS</span>; however, when <span class="highlight">eSetValueWithoutOverwrite</span> is used, it returns <span class="highlight">pdFAIL</span> if an unread notification is already pending.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xTaskNotifyAndQueryFromISR(
    TaskHandle_t xTaskToNotify, 
    uint32_t ulValue, 
    eNotifyAction eAction, 
    uint32_t * pulPreviousNotificationValue
    BaseType_t * pxHigherPriorityTaskWoken)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xTaskNotifyAndQueryFromISR</span><span style="color: #D5CED9">(</span></span>
<span class="line"><span style="color: #D5CED9">    TaskHandle_t </span><span style="color: #00E8C6">xTaskToNotify</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">ulValue</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">    eNotifyAction </span><span style="color: #00E8C6">eAction</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> pulPreviousNotificationValue</span></span>
<span class="line"><span style="color: #D5CED9">    BaseType_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxHigherPriorityTaskWoken</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="task_notify_take" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
ulTaskNotifyTake()
</b>

<p>
<span class="highlight">ulTaskNotifyTake()</span> allows the calling task to block until its notification value becomes nonzero or the specified timeout expires. When a notification is received, setting <span class="highlight">xClearCountOnExit</span> to <span class="highlight">pdTRUE</span> clears the notification value to zero, providing binary-semaphore behavior. Setting it to <span class="highlight">pdFALSE</span> decrements the value by one, providing counting-semaphore behavior. The function returns the notification value before it is cleared or decremented, or 0 if the wait period expires without a notification.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>uint32_t ulTaskNotifyTake(BaseType_t xClearCountOnExit, 
                          TickType_t xTicksToWait)
                          
// ---------------------- Example ----------------------

uint32_t NotifyValue;
NotifyValue = ulTaskNotifyTake(pdTRUE, portMAX_DELAY);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">ulTaskNotifyTake</span><span style="color: #D5CED9">(BaseType_t </span><span style="color: #00E8C6">xClearCountOnExit</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                          TickType_t </span><span style="color: #00E8C6">xTicksToWait</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">                          </span></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> NotifyValue;</span></span>
<span class="line"><span style="color: #D5CED9">NotifyValue </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">ulTaskNotifyTake</span><span style="color: #D5CED9">(pdTRUE, portMAX_DELAY);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="task_notify_wait" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xTaskNotifyWait()
</b>

<p>
<span class="highlight">xTaskNotifyWait()</span> blocks the calling task until a notification becomes pending or the specified timeout expires. It can clear selected bits in the task&#8217;s notification value before waiting and clear additional bits after the received value has been copied to <span class="highlight">pulNotificationValue</span>. This makes it well suited for receiving event flags or a 32-bit mailbox value sent through <span class="highlight">xTaskNotify()</span>. The function returns <span class="highlight">pdTRUE</span> when a notification is received and <span class="highlight">pdFALSE</span> if the wait period expires without one.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xTaskNotifyWait(uint32_t ulBitsToClearOnEntry,
                           uint32_t ulBitsToClearOnExit, 
                           uint32_t * pulNotificationValue, 
                           TickType_t xTicksToWait)
                           
// ---------------------- Example ----------------------

uint32_t NotifyValue;
BaseType_t err;
err = xTaskNotifyWait((uint32_t	 ) 0x00,		       // Clear no bits before waiting
							        (uint32_t	 ) ULONG_MAX,	     // Clear all bits after receiving
							        (uint32_t* ) &amp;NotifyValue,   // Store the received notification value  
							        (TickType_t) portMAX_DELAY); // Wait indefinitely                           </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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xTaskNotifyWait</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">ulBitsToClearOnEntry</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                           </span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">ulBitsToClearOnExit</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                           </span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pulNotificationValue</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                           TickType_t </span><span style="color: #00E8C6">xTicksToWait</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">                           </span></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9"> NotifyValue;</span></span>
<span class="line"><span style="color: #D5CED9">BaseType_t err;</span></span>
<span class="line"><span style="color: #D5CED9">err </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xTaskNotifyWait</span><span style="color: #D5CED9">((</span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9">	 ) </span><span style="color: #C74DED">0x</span><span style="color: #F39C12">00</span><span style="color: #D5CED9">,</span><span style="color: #A0A1A7CC">		       // Clear no bits before waiting</span></span>
<span class="line"><span style="color: #D5CED9">							        (</span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9">	 ) </span><span style="color: #00E8C6">ULONG_MAX</span><span style="color: #D5CED9">,</span><span style="color: #A0A1A7CC">	     // Clear all bits after receiving</span></span>
<span class="line"><span style="color: #D5CED9">							        (</span><span style="color: #C74DED">uint32_t</span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> ) </span><span style="color: #EE5D43">&amp;</span><span style="color: #00E8C6">NotifyValue</span><span style="color: #D5CED9">,</span><span style="color: #A0A1A7CC">   // Store the received notification value  </span></span>
<span class="line"><span style="color: #D5CED9">							        (TickType_t) </span><span style="color: #00E8C6">portMAX_DELAY</span><span style="color: #D5CED9">);</span><span style="color: #A0A1A7CC"> // Wait indefinitely                           </span></span></code></pre></div>



<br><br>
<a href="#top" style="font-size:20px; color: blue;">Back to top of the page</a>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">7813</post-id>	</item>
		<item>
		<title>FreeRTOS vs. Zephyr RTOS</title>
		<link>https://hangpersonal.com/2026/07/20/freertos-vs-zephyr/</link>
		
		<dc:creator><![CDATA[hangcui1201]]></dc:creator>
		<pubDate>Mon, 20 Jul 2026 16:40:47 +0000</pubDate>
				<category><![CDATA[Embedded System]]></category>
		<guid isPermaLink="false">https://hangpersonal.com/?p=7585</guid>

					<description><![CDATA[FreeRTOS is a lightweight, production-proven real-time kernel maintained by AWS under the MIT license. Built for resource-constrained microcontrollers, it delivers deterministic task scheduling, queues, semaphores, mutexes, and memory management with minimal flash and RAM usage. Its modular, vendor-neutral design integrates easily with custom toolchains, hardware platforms, and abstraction layers, making it a strong choice for...]]></description>
										<content:encoded><![CDATA[
<div class="article-text" style="margin-top:30px; margin-bottom:50px;">

<p>
<b>FreeRTOS</b> is a lightweight, production-proven real-time kernel maintained by AWS under the MIT license. Built for resource-constrained microcontrollers, it delivers deterministic task scheduling, queues, semaphores, mutexes, and memory management with minimal flash and RAM usage. Its modular, vendor-neutral design integrates easily with custom toolchains, hardware platforms, and abstraction layers, making it a strong choice for fast, predictable, low-level embedded systems.
</p>

<p>
<b>Zephyr</b> is a modern, full-featured RTOS hosted by the Linux Foundation under the Apache 2.0 license. Inspired by Linux, it combines standardized drivers, Devicetree and Kconfig configuration, built-in networking and wireless stacks, and security features such as MPU-based isolation. Its vendor-neutral, platform-oriented architecture enables developers to build secure, scalable IoT applications that can be ported across a wide range of hardware.
</p>


</div>


            <div  class="spbtbl-wrapper spbtbl-blockmode spbtbl-fullwidth" >
                                <table class="spbtbl-style spbtbl-color-blue" title="FreeRTOS vs Zephyr RTOS"  itemscope itemtype="http://schema.org/Table" >
                    <!-- Superb Tables Plugin -->
                    <thead>
                        <tr>
                            <th style="font-size: 18px !important;"  itemprop="name"  align="left">Feature / Concept</th><th style="font-size: 18px !important;"  itemprop="name"  align="left">FreeRTOS</th><th style="font-size: 18px !important;"  itemprop="name"  align="left">Zephyr RTOS</th>                        </tr>
                    </thead>
                    <tbody>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >License &amp; Sponsor</td>                                    <td style="font-size:18px !important;" itemprop="description" >Amazon Web Services (AWS) / MIT</td>                                    <td style="font-size:18px !important;" itemprop="description" >Linux Foundation / Apache 2.0</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Core Philosophy</td>                                    <td style="font-size:18px !important;" itemprop="description" >Minimalist kernel &amp; task scheduler</td>                                    <td style="font-size:18px !important;" itemprop="description" >Full-featured platform ecosystem</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Execution Primitives</td>                                    <td style="font-size:18px !important;" itemprop="description" >Tasks</td>                                    <td style="font-size:18px !important;" itemprop="description" >Threads, work queues, system work queue</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >System Options</td>                                    <td style="font-size:18px !important;" itemprop="description" >C Header file (FreeRTOSConfig.h)</td>                                    <td style="font-size:18px !important;" itemprop="description" >Kconfig (prj.conf)</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Hardware Description</td>                                    <td style="font-size:18px !important;" itemprop="description" >Vendor initialization code &amp; manual board support</td>                                    <td style="font-size:18px !important;" itemprop="description" >Devicetree (.dts), overlays, and bindings</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Abstraction Layer</td>                                    <td style="font-size:18px !important;" itemprop="description" >Vendor HALs (e.g., STM32 HAL, ESP-IDF)</td>                                    <td style="font-size:18px !important;" itemprop="description" >Universal, vendor-neutral driver APIs</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >App Portability</td>                                    <td style="font-size:18px !important;" itemprop="description" >Vendor/chip-specific projects</td>                                    <td style="font-size:18px !important;" itemprop="description" >Highly portable across boards and silicon vendors</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Networking &amp; Connectivity</td>                                    <td style="font-size:18px !important;" itemprop="description" >Manual integration (or AWS IoT / FreeRTOS-Plus-TCP)</td>                                    <td style="font-size:18px !important;" itemprop="description" >Built-in IPv4/IPv6, Ethernet, Wi-Fi, BLE, Mesh</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >System Services</td>                                    <td style="font-size:18px !important;" itemprop="description" >Custom logging, optional third-party components</td>                                    <td style="font-size:18px !important;" itemprop="description" >Built-in Logging subsystem, Shell CLI, USB, POSIX</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Memory Isolation</td>                                    <td style="font-size:18px !important;" itemprop="description" >Flat memory space (optional FreeRTOS-MPU)</td>                                    <td style="font-size:18px !important;" itemprop="description" >Native User/Kernel mode isolation &amp; MPU support</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Build System &amp; Tools</td>                                    <td style="font-size:18px !important;" itemprop="description" >Vendor IDEs (Keil, STM32CubeIDE), Make, CMake</td>                                    <td style="font-size:18px !important;" itemprop="description" >west meta-tool, CMake, and Zephyr SDK</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Flash / RAM Footprint</td>                                    <td style="font-size:18px !important;" itemprop="description" >Tiny (~5–10 KB Flash base)</td>                                    <td style="font-size:18px !important;" itemprop="description" >Scalable (~15–50+ KB Flash depending on modules)</td>                            </tr>
                                            </tbody>
                </table>
                            </div>




<div class="article-text" style="margin-top:30px; margin-bottom:30px;">

<p>
<b>FreeRTOS (Scheduler)</b>: FreeRTOS provides core RTOS primitives, tasks, semaphores, queues, and software timers. It leaves driver implementation, networking, and hardware configuration up to you or your target MCU&#8217;s vendor HAL.
</p>

<p>
<b>Zephyr (Platform)</b>: Zephyr takes a batteries-included approach. It includes unified driver models, a shell interface, power management, filesystems, and security modules built directly into the tree.
</p>

</div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
Configuration &amp; Developer Workflow
</b>

<p>
<b>FreeRTOS</b>: Configuration is managed through a single FreeRTOSConfig.h file. You can easily integrate it into almost any vendor IDE (Keil, IAR, STM32CubeIDE) or custom Makefile/CMake environment.
</p>

<p>
<b>Zephyr</b>: Mimics the Linux kernel build process. Hardware is described using <span class="highlight">Devicetree (.dts)</span>, while software components are toggled using <span class="highlight">Kconfig (prj.conf)</span>. The meta-tool west manages repositories and builds, offering high cross-platform portability at the cost of a steeper initial learning curve.
</p>

</div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
Memory Protection &amp; Performance
</b>

<p>
<b>FreeRTOS</b>: Has lower context-switching and interrupt overhead because of its lean execution model. Tasks generally execute in a single shared memory space.
</p>

<p>
<b>Zephyr</b>: Emphasizes safety and isolation. On supported hardware, it separates kernel mode from user mode and enforces hardware stack protection and memory partitions using the Memory Protection Unit (MPU).
</p>

</div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
FreeRTOS API vs. Zephyr API
</b>

</div>


            <div  class="spbtbl-wrapper spbtbl-blockmode spbtbl-fullwidth" >
                                <table class="spbtbl-style spbtbl-color-blue" title="FreeRTOS API vs. Zephyr API"  itemscope itemtype="http://schema.org/Table" >
                    <!-- Superb Tables Plugin -->
                    <thead>
                        <tr>
                            <th style="font-size: 18px !important;"  itemprop="name"  align="left">Concept</th><th style="font-size: 18px !important;"  itemprop="name"  align="left">FreeRTOS API</th><th style="font-size: 18px !important;"  itemprop="name"  align="left">Zephyr RTOS API</th>                        </tr>
                    </thead>
                    <tbody>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Thread Creation</td>                                    <td style="font-size:18px !important;" itemprop="description" >xTaskCreate()</td>                                    <td style="font-size:18px !important;" itemprop="description" >k_thread_create()</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Thread Delay</td>                                    <td style="font-size:18px !important;" itemprop="description" >vTaskDelay()</td>                                    <td style="font-size:18px !important;" itemprop="description" >k_sleep()<br>k_msleep()</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Binary Semaphore</td>                                    <td style="font-size:18px !important;" itemprop="description" >xSemaphoreCreateBinary()<br>xSemaphoreTake()</td>                                    <td style="font-size:18px !important;" itemprop="description" >K_SEM_DEFINE(..., 0, 1)<br>k_sem_take()</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Mutex</td>                                    <td style="font-size:18px !important;" itemprop="description" >xSemaphoreCreateMutex()<br>xSemaphoreTake()</td>                                    <td style="font-size:18px !important;" itemprop="description" >K_MUTEX_DEFINE(...)<br>k_mutex_lock()</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Event Group</td>                                    <td style="font-size:18px !important;" itemprop="description" >xEventGroupCreate()</td>                                    <td style="font-size:18px !important;" itemprop="description" >k_event_init()</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Message Queue</td>                                    <td style="font-size:18px !important;" itemprop="description" >xQueueCreate()<br>xQueueSend()</td>                                    <td style="font-size:18px !important;" itemprop="description" >k_msgq_init()<br>k_msgq_put()</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Direct Notification</td>                                    <td style="font-size:18px !important;" itemprop="description" >Task Notification<br>xTaskNotify()</td>                                    <td style="font-size:18px !important;" itemprop="description" >Semaphore<br>k_event, or k_poll_signal</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Timers</td>                                    <td style="font-size:18px !important;" itemprop="description" >Software Timer<br>xTimerCreate()</td>                                    <td style="font-size:18px !important;" itemprop="description" >Kernel Timer<br>k_timer_init()</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Background Exec</td>                                    <td style="font-size:18px !important;" itemprop="description" >Daemon / Timer Task</td>                                    <td style="font-size:18px !important;" itemprop="description" >System Work Queue k_work_submit()</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >Interrupt APIs</td>                                    <td style="font-size:18px !important;" itemprop="description" >Separate ...FromISR() APIs</td>                                    <td style="font-size:18px !important;" itemprop="description" >Unified APIs (e.g., k_sem_give() works in ISR)</td>                            </tr>
                                            </tbody>
                </table>
                            </div>




<br><br>
<a href="#top" style="font-size:20px; color: blue;">Back to top of the page</a>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">7585</post-id>	</item>
		<item>
		<title>STM32 FreeRTOS: Event Groups</title>
		<link>https://hangpersonal.com/2026/07/17/stm32-freertos-event-group/</link>
		
		<dc:creator><![CDATA[hangcui1201]]></dc:creator>
		<pubDate>Sat, 18 Jul 2026 04:47:38 +0000</pubDate>
				<category><![CDATA[Embedded System]]></category>
		<guid isPermaLink="false">https://hangpersonal.com/?p=7579</guid>

					<description><![CDATA[STM32 Microcontroller and FreeRTOS Development Event Groups Event groups allow a task to wait in the blocked state for a combination of one of more events to occur. Event groups unblock all the tasks that were waiting for the same event, or combination of events, when the event occurs. Event groups reduce RAM usage by...]]></description>
										<content:encoded><![CDATA[
<a href="https://hangpersonal.com/embedded-system/stm32-mcu/freertos-tutorials/" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
STM32 Microcontroller and FreeRTOS Development
</a>
<br><br>



<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


            <div  class="spbtbl-wrapper spbtbl-blockmode spbtbl-fullwidth" >
                                <table class="spbtbl-style spbtbl-color-blue" title="FreeRTOS: Event Group"  itemscope itemtype="http://schema.org/Table" >
                    <!-- Superb Tables Plugin -->
                    <thead>
                        <tr>
                            <th style="font-size: 18px !important;"  itemprop="name"  align="left">Event Group API Function</th><th style="font-size: 18px !important;"  itemprop="name"  align="left">Description</th>                        </tr>
                    </thead>
                    <tbody>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#event_group_create" style="font-size: 20px;color: blue">xEventGroupCreate()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Create an event group using dynamic memory allocation</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#event_group_create_static" style="font-size: 20px;color: blue">xEventGroupCreateStatic()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Create an event group using user-provided static memory</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#event_group_clear_bits" style="font-size: 20px;color: blue">xEventGroupClearBits()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Clear specified event bits from an event group</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#event_group_clear_bits_from_isr" style="font-size: 20px;color: blue">xEventGroupClearBitsFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Request specified event bits to be cleared from an ISR</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#event_group_set_bits" style="font-size: 20px;color: blue">xEventGroupSetBits()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Set specified event bits in an event group</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#event_group_set_bits_from_isr" style="font-size: 20px;color: blue">xEventGroupSetBitsFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Request specified event bits to be set from an ISR</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#event_group_get_bits" style="font-size: 20px;color: blue">xEventGroupGetBits()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Return the current event-bit value of an event group</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#event_group_get_bits_from_isr" style="font-size: 20px;color: blue">xEventGroupGetBitsFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Return the current event-bit value from an ISR</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#event_group_wait_bits" style="font-size: 20px;color: blue">xEventGroupWaitBits()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Block a task until specified event bits are set or a timeout occurs</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#event_group_sync" style="font-size: 20px;color: blue">xEventGroupSync()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Sets event bits and waits for all specified bits</td>                            </tr>
                                            </tbody>
                </table>
                            </div>




<div class="article-text" style="margin-top:20px; margin-bottom:30px;">

<b style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
Event Groups
</b>

<p>
Event groups allow a task to wait in the blocked state for a combination of one of more events to occur. Event groups unblock all the tasks that were waiting for the same event, or combination of events, when the event occurs. Event groups reduce RAM usage by allowing us to replace multiple binary semaphores with a single event group.

<ul>
<li> Synchronizing tasks
</li>
<li>Broadcasting events to multiple tasks
</li>
</ul>

</p>

</div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
Event Bits
</b>

<p>
When <span class="highlight">configUSE_16_BIT_TICKS</span> is set to 0, <span class="highlight">TickType_t</span> is a 32-bit data type, so <span class="highlight">EventBits_t</span> is also a 32-bit data type. A variable of type <span class="highlight">EventBits_t</span> can store 24 event bits, while the upper 8 bits are reserved for internal use. Event bit 0 is stored in bit 0 of the variable, event bit 1 is stored in bit 1, and so on. For STM32 devices, an event group can therefore contain up to 24 usable event bits.
</p>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img fetchpriority="high" decoding="async" width="1024" height="195" src="https://hangpersonal.com/wp-content/uploads/2026/07/event_group-1024x195.png" alt="" class="wp-image-7750" style="width:700px" srcset="https://hangpersonal.com/wp-content/uploads/2026/07/event_group-1024x195.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/07/event_group-300x57.png 300w, https://hangpersonal.com/wp-content/uploads/2026/07/event_group-768x146.png 768w, https://hangpersonal.com/wp-content/uploads/2026/07/event_group-1536x292.png 1536w, https://hangpersonal.com/wp-content/uploads/2026/07/event_group-2048x389.png 2048w, https://hangpersonal.com/wp-content/uploads/2026/07/event_group-850x161.png 850w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:40px; margin-bottom:30px;">

<p>
</p><ul>

<li>
An event group is a set of event flags
</li>

<li>An event flag is a boolean value (1 or 0) used to indicate whether an event has occurred or not
</li>

<li>An event flag is stored in a single bit and the state of all event flags can be stored in a single variable
</li>

</ul>
<p></p>

</div>



<div class="article-text" style="margin-top:60px; margin-bottom:30px;">

<b id="event_group_create" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xEventGroupCreate()
</b>

<p>
<span class="highlight">xEventGroupCreate()</span> dynamically allocates the required memory and creates a new event group. It returns an <span class="highlight">EventGroupHandle_t</span> for use with other event-group functions, or NULL if memory allocation fails. This function is available only when <span class="highlight">configSUPPORT_DYNAMIC_ALLOCATION</span> is enabled. When the event group is no longer needed, call <span class="highlight">vEventGroupDelete()</span> to free the allocated memory.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>EventGroupHandle_t xEventGroupCreate(void)

// ---------------------- Example ----------------------

EventGroupHandle_t xEventGroupHandler;
xEventGroupHandler = xEventGroupCreate();</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">EventGroupHandle_t </span><span style="color: #FFE66D">xEventGroupCreate</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">EventGroupHandle_t xEventGroupHandler;</span></span>
<span class="line"><span style="color: #D5CED9">xEventGroupHandler </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xEventGroupCreate</span><span style="color: #D5CED9">();</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="event_group_create_static" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xEventGroupCreateStatic()
</b>

<p>
<span class="highlight">xEventGroupCreateStatic()</span> creates an event group using memory supplied by the application rather than allocating memory from the FreeRTOS heap. The application must provide a <span class="highlight">StaticEventGroup_t</span> variable that remains valid for the entire lifetime of the event group. This function is useful in systems that require deterministic memory usage or do not permit dynamic allocation, and it is available only when <span class="highlight">configSUPPORT_STATIC_ALLOCATION</span> is enabled.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>EventGroupHandle_t xEventGroupCreateStatic(StaticEventGroup_t *pxEventGroupBuffer)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">EventGroupHandle_t </span><span style="color: #FFE66D">xEventGroupCreateStatic</span><span style="color: #D5CED9">(StaticEventGroup_t </span><span style="color: #EE5D43">*</span><span style="color: #00E8C6">pxEventGroupBuffer</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="event_group_clear_bits" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xEventGroupClearBits()
</b>

<p>
<span class="highlight">xEventGroupClearBits()</span> clears one or more specified bits in an event group from task context. The bits are selected using a bit mask: each bit set to 1 in the mask is cleared, while all other bits remain unchanged. The function returns the event-group value before the bits were cleared, allowing the task to inspect the previous event state. It must not be called from an interrupt service routine.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>EventBits_t xEventGroupClearBits(EventGroupHandle_t xEventGroup, 
                                 const EventBits_t uxBitsToClear)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">EventBits_t </span><span style="color: #FFE66D">xEventGroupClearBits</span><span style="color: #D5CED9">(EventGroupHandle_t </span><span style="color: #00E8C6">xEventGroup</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                                 </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> EventBits_t </span><span style="color: #00E8C6">uxBitsToClear</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="event_group_clear_bits_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xEventGroupClearBitsFromISR()
</b>

<p>
<span class="highlight">xEventGroupClearBitsFromISR()</span> requests that one or more specified event bits be cleared from interrupt context. Because clearing event bits may unblock multiple waiting tasks, the operation is deferred to the FreeRTOS timer daemon task rather than performed directly within the ISR. The function returns <span class="highlight">pdPASS</span> if the request is successfully posted to the timer command queue, or <span class="highlight">pdFAIL</span> if the queue is full.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xEventGroupClearBitsFromISR(EventGroupHandle_t xEventGroup, 
                                       const EventBits_t uxBitsToSet)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xEventGroupClearBitsFromISR</span><span style="color: #D5CED9">(EventGroupHandle_t </span><span style="color: #00E8C6">xEventGroup</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                                       </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> EventBits_t </span><span style="color: #00E8C6">uxBitsToSet</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="event_group_set_bits" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xEventGroupSetBits()
</b>

<p>
<span class="highlight">xEventGroupSetBits()</span> sets one or more specified bits in an event group from task context. Tasks waiting for those bits are then evaluated and may be moved from the Blocked state to the Ready state. Multiple bits can be set simultaneously by combining them with the bitwise OR operator. The function returns the event-group value after the bits have been set and any automatically cleared bits have been processed.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>EventBits_t xEventGroupSetBits(EventGroupHandle_t xEventGroup, 
                               const EventBits_t uxBitsToSet)

// ---------------------- Example ---------------------- 

#define EVENTBIT_0	 (1 &lt;&lt; 0)
#define EVENTBIT_1	 (1 &lt;&lt; 1)
#define EVENTBIT_2	 (1 &lt;&lt; 2)
#define EVENTBIT_ALL (EVENTBIT_0 | EVENTBIT_1 | EVENTBIT_2)
                              
xEventGroupSetBits(xEventGroupHandler, EVENTBIT_1);
xEventGroupSetBits(xEventGroupHandler, EVENTBIT_2);                               </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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">EventBits_t </span><span style="color: #FFE66D">xEventGroupSetBits</span><span style="color: #D5CED9">(EventGroupHandle_t </span><span style="color: #00E8C6">xEventGroup</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                               </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> EventBits_t </span><span style="color: #00E8C6">uxBitsToSet</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ---------------------- </span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">EVENTBIT_0</span><span style="color: #D5CED9">	 (</span><span style="color: #F39C12">1</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">&lt;&lt;</span><span style="color: #D5CED9"> </span><span style="color: #F39C12">0</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">EVENTBIT_1</span><span style="color: #D5CED9">	 (</span><span style="color: #F39C12">1</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">&lt;&lt;</span><span style="color: #D5CED9"> </span><span style="color: #F39C12">1</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">EVENTBIT_2</span><span style="color: #D5CED9">	 (</span><span style="color: #F39C12">1</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">&lt;&lt;</span><span style="color: #D5CED9"> </span><span style="color: #F39C12">2</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">EVENTBIT_ALL</span><span style="color: #D5CED9"> (EVENTBIT_0 </span><span style="color: #EE5D43">|</span><span style="color: #D5CED9"> EVENTBIT_1 </span><span style="color: #EE5D43">|</span><span style="color: #D5CED9"> EVENTBIT_2)</span></span>
<span class="line"><span style="color: #D5CED9">                              </span></span>
<span class="line"><span style="color: #FFE66D">xEventGroupSetBits</span><span style="color: #D5CED9">(xEventGroupHandler, EVENTBIT_1);</span></span>
<span class="line"><span style="color: #FFE66D">xEventGroupSetBits</span><span style="color: #D5CED9">(xEventGroupHandler, EVENTBIT_2);                               </span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="event_group_set_bits_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xEventGroupSetBitsFromISR()
</b>

<p>
<span class="highlight">xEventGroupSetBitsFromISR()</span> requests that one or more event bits be set from an interrupt service routine. Because setting event bits may unblock multiple tasks and is not a constant-time operation, the request is deferred to the FreeRTOS timer daemon task. The <span class="highlight">xHigherPriorityTaskWoken</span> parameter indicates whether processing the request may make a higher-priority task ready to run. The function returns <span class="highlight">pdPASS</span> if the request is successfully posted to the timer command queue, or <span class="highlight">pdFAIL</span> if the queue is full.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xEventGroupSetBitsFromISR(EventGroupHandle_t xEventGroup, 
                                     const EventBits_t uxBitsToSet, 
                                     BaseType_t * pxHigherPriorityTaskWoken)
                                     
// ---------------------- Example ----------------------

BaseType_t YieldRequired = pdFALSE;
BaseType_t xHigherPriorityTaskWoken;

YieldRequired = xEventGroupSetBitsFromISR(xEventGroupHandler,
    											                EVENTBIT_0,
												                  &amp;xHigherPriorityTaskWoken);	
												                  
if(YieldRequired != pdFAIL) {
    portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}                                      </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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xEventGroupSetBitsFromISR</span><span style="color: #D5CED9">(EventGroupHandle_t </span><span style="color: #00E8C6">xEventGroup</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                                     </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> EventBits_t </span><span style="color: #00E8C6">uxBitsToSet</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                                     BaseType_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxHigherPriorityTaskWoken</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">                                     </span></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">BaseType_t YieldRequired </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> pdFALSE;</span></span>
<span class="line"><span style="color: #D5CED9">BaseType_t xHigherPriorityTaskWoken;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">YieldRequired </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xEventGroupSetBitsFromISR</span><span style="color: #D5CED9">(xEventGroupHandler,</span></span>
<span class="line"><span style="color: #D5CED9">    											                EVENTBIT_0,</span></span>
<span class="line"><span style="color: #D5CED9">												                  </span><span style="color: #EE5D43">&amp;</span><span style="color: #00E8C6">xHigherPriorityTaskWoken</span><span style="color: #D5CED9">);	</span></span>
<span class="line"><span style="color: #D5CED9">												                  </span></span>
<span class="line"><span style="color: #C74DED">if</span><span style="color: #D5CED9">(YieldRequired </span><span style="color: #EE5D43">!=</span><span style="color: #D5CED9"> pdFAIL) {</span></span>
<span class="line"><span style="color: #D5CED9">    </span><span style="color: #FFE66D">portYIELD_FROM_ISR</span><span style="color: #D5CED9">(xHigherPriorityTaskWoken);</span></span>
<span class="line"><span style="color: #D5CED9">}                                      </span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="event_group_get_bits" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xEventGroupGetBits()
</b>

<p>
<span class="highlight">xEventGroupGetBits()</span> reads and returns the current value of an event group from task context without modifying any bits. The returned <span class="highlight">EventBits_t</span> value can be tested with bit masks to determine which events are currently set. Because another task or interrupt may change the event group immediately afterward, the returned value should be treated as a snapshot of its state at the time of the call.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>EventBits_t xEventGroupGetBits(EventGroupHandle_t xEventGroup)

// ---------------------- Example ----------------------

EventBits_t newValue;
newValue = xEventGroupGetBits(xEventGroupHandler);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">EventBits_t </span><span style="color: #FFE66D">xEventGroupGetBits</span><span style="color: #D5CED9">(EventGroupHandle_t </span><span style="color: #00E8C6">xEventGroup</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">EventBits_t newValue;</span></span>
<span class="line"><span style="color: #D5CED9">newValue </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xEventGroupGetBits</span><span style="color: #D5CED9">(xEventGroupHandler);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="event_group_get_bits_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xEventGroupGetBitsFromISR()
</b>

<p>
<span class="highlight">xEventGroupGetBitsFromISR()</span> reads and returns the current value of an event group from interrupt context without modifying any bits. It provides an ISR-safe way to check which event conditions are currently set. Like <span class="highlight">xEventGroupGetBits()</span>, the returned value is only a snapshot of the event group at the time of the call and may change immediately afterward.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>EventBits_t xEventGroupGetBitsFromISR(EventGroupHandle_t xEventGroup)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">EventBits_t </span><span style="color: #FFE66D">xEventGroupGetBitsFromISR</span><span style="color: #D5CED9">(EventGroupHandle_t </span><span style="color: #00E8C6">xEventGroup</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="event_group_wait_bits" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xEventGroupWaitBits()
</b>

<p>
<span class="highlight">xEventGroupWaitBits()</span> allows a task to wait for one or more specified event bits. The task can be configured to unblock when either any requested bit is set or all requested bits are set. It can also automatically clear the matched bits before returning and wait indefinitely or for a specified timeout. The function returns the event-group value that caused the task to unblock, or the value present when the timeout expired.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>EventBits_t xEventGroupWaitBits(EventGroupHandle_t xEventGroup,
                                const EventBits_t uxBitsToWaitFor,
                                const BaseType_t xClearOnExit,
                                const BaseType_t xWaitForAllBits,
                                const TickType_t xTicksToWait)
                                
// ---------------------- Example ----------------------

EventBits_t EventValue;

// This code blocks the current FreeRTOS task until all event bits
// specified by EVENTBIT_ALL are set
EventValue = xEventGroupWaitBits((EventGroupHandle_t) xEventGroupHandler,
						     				         (EventBits_t		    ) EVENTBIT_ALL,
										             (BaseType_t		    ) pdTRUE,
										             (BaseType_t		    ) pdTRUE,
								                 (TickType_t		    ) portMAX_DELAY);   

// This call blocks the current task until any bit defined in EVENTBIT_ALL becomes set, 
// then clears the matched event bits and stores the previous event-group value in EventValue
EventValue = xEventGroupWaitBits((EventGroupHandle_t) xEventGroupHandler, // Event group to monitor
						     				         (EventBits_t		    ) EVENTBIT_ALL,       // Bit mask to wait for
										             (BaseType_t		    ) pdTRUE,             // Clear matched bits before returning
										             (BaseType_t		    ) pdFALSE,            // Wait for ANY bit, not all bits
								                 (TickType_t		    ) portMAX_DELAY);     // Wait indefinitely     								                                              </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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">EventBits_t </span><span style="color: #FFE66D">xEventGroupWaitBits</span><span style="color: #D5CED9">(EventGroupHandle_t </span><span style="color: #00E8C6">xEventGroup</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> EventBits_t </span><span style="color: #00E8C6">uxBitsToWaitFor</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> BaseType_t </span><span style="color: #00E8C6">xClearOnExit</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> BaseType_t </span><span style="color: #00E8C6">xWaitForAllBits</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> TickType_t </span><span style="color: #00E8C6">xTicksToWait</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">                                </span></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">EventBits_t EventValue;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// This code blocks the current FreeRTOS task until all event bits</span></span>
<span class="line"><span style="color: #A0A1A7CC">// specified by EVENTBIT_ALL are set</span></span>
<span class="line"><span style="color: #D5CED9">EventValue </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xEventGroupWaitBits</span><span style="color: #D5CED9">((EventGroupHandle_t) </span><span style="color: #00E8C6">xEventGroupHandler</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">						     				         (EventBits_t		    ) </span><span style="color: #00E8C6">EVENTBIT_ALL</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">										             (BaseType_t		    ) </span><span style="color: #00E8C6">pdTRUE</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">										             (BaseType_t		    ) </span><span style="color: #00E8C6">pdTRUE</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">								                 (TickType_t		    ) </span><span style="color: #00E8C6">portMAX_DELAY</span><span style="color: #D5CED9">);   </span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// This call blocks the current task until any bit defined in EVENTBIT_ALL becomes set, </span></span>
<span class="line"><span style="color: #A0A1A7CC">// then clears the matched event bits and stores the previous event-group value in EventValue</span></span>
<span class="line"><span style="color: #D5CED9">EventValue </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xEventGroupWaitBits</span><span style="color: #D5CED9">((EventGroupHandle_t) </span><span style="color: #00E8C6">xEventGroupHandler</span><span style="color: #D5CED9">,</span><span style="color: #A0A1A7CC"> // Event group to monitor</span></span>
<span class="line"><span style="color: #D5CED9">						     				         (EventBits_t		    ) </span><span style="color: #00E8C6">EVENTBIT_ALL</span><span style="color: #D5CED9">,</span><span style="color: #A0A1A7CC">       // Bit mask to wait for</span></span>
<span class="line"><span style="color: #D5CED9">										             (BaseType_t		    ) </span><span style="color: #00E8C6">pdTRUE</span><span style="color: #D5CED9">,</span><span style="color: #A0A1A7CC">             // Clear matched bits before returning</span></span>
<span class="line"><span style="color: #D5CED9">										             (BaseType_t		    ) </span><span style="color: #00E8C6">pdFALSE</span><span style="color: #D5CED9">,</span><span style="color: #A0A1A7CC">            // Wait for ANY bit, not all bits</span></span>
<span class="line"><span style="color: #D5CED9">								                 (TickType_t		    ) </span><span style="color: #00E8C6">portMAX_DELAY</span><span style="color: #D5CED9">);</span><span style="color: #A0A1A7CC">     // Wait indefinitely     								                                              </span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="event_group_sync" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xEventGroupSync()
</b>

<p>
<span class="highlight">xEventGroupSync()</span> synchronizes multiple tasks at a common execution point. It atomically sets the event bits specified by <span class="highlight">uxBitsToSet</span>, then blocks the calling task until all bits in <span class="highlight">uxBitsToWaitFor</span> are set or the timeout expires. The function returns the event-group value that caused the task to unblock, allowing the task to determine whether synchronization was completed successfully.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>EventBits_t xEventGroupSync(EventGroupHandle_t xEventGroup, 
                            const EventBits_t uxBitsToSet, 
                            const EventBits_t uxBitsToWaitFor, 
                            TickType_t xTicksToWait)
                            
// ---------------------- Example ----------------------

#define TASK1_BIT (1UL &lt;&lt; 0UL)
#define TASK2_BIT (1UL &lt;&lt; 1UL)
#define TASK3_BIT (1UL &lt;&lt; 2UL)

EventGroupHandle_t xEventGroup;
EventBits_t uxAllSyncBits = (TASK1_BIT | TASK2_BIT | TASK3_BIT);

xEventGroup = xEventGroupCreate();

void vTask1Task(void *pvParameters) {
	EventBits_t uxReturn;
	while(1) {
		uxReturn = xEventGroupSync(xEventGroup, TASK1_BIT, uxAllSyncBits, portMAX_DELAY);
		if( uxAllSyncBits == (uxReturn &amp; uxAllSyncBits) ) {
			// Do something
		}
	}
}

void vTask2Task(void *pvParameters) {
	EventBits_t uxReturn;
	while(1) {
		uxReturn = xEventGroupSync(xEventGroup, TASK2_BIT, uxAllSyncBits, portMAX_DELAY);
		if( uxAllSyncBits == (uxReturn &amp; uxAllSyncBits) ) {
			// Do something
		}
	}
}

void vTask3Task(void *pvParameters) {
	EventBits_t uxReturn;
	while(1) {
		uxReturn = xEventGroupSync(xEventGroup, TASK3_BIT, uxAllSyncBits, portMAX_DELAY);
		if( uxAllSyncBits == (uxReturn &amp; uxAllSyncBits) ) {
			// Do something
			printf("All tasks set \r\n");
			vTaskDelay(_200ms);
		}
	}
}                            </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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">EventBits_t </span><span style="color: #FFE66D">xEventGroupSync</span><span style="color: #D5CED9">(EventGroupHandle_t </span><span style="color: #00E8C6">xEventGroup</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                            </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> EventBits_t </span><span style="color: #00E8C6">uxBitsToSet</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                            </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> EventBits_t </span><span style="color: #00E8C6">uxBitsToWaitFor</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                            TickType_t </span><span style="color: #00E8C6">xTicksToWait</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">                            </span></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">TASK1_BIT</span><span style="color: #D5CED9"> (</span><span style="color: #F39C12">1</span><span style="color: #C74DED">UL</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">&lt;&lt;</span><span style="color: #D5CED9"> </span><span style="color: #F39C12">0</span><span style="color: #C74DED">UL</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">TASK2_BIT</span><span style="color: #D5CED9"> (</span><span style="color: #F39C12">1</span><span style="color: #C74DED">UL</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">&lt;&lt;</span><span style="color: #D5CED9"> </span><span style="color: #F39C12">1</span><span style="color: #C74DED">UL</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">TASK3_BIT</span><span style="color: #D5CED9"> (</span><span style="color: #F39C12">1</span><span style="color: #C74DED">UL</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">&lt;&lt;</span><span style="color: #D5CED9"> </span><span style="color: #F39C12">2</span><span style="color: #C74DED">UL</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">EventGroupHandle_t xEventGroup;</span></span>
<span class="line"><span style="color: #D5CED9">EventBits_t uxAllSyncBits </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> (TASK1_BIT </span><span style="color: #EE5D43">|</span><span style="color: #D5CED9"> TASK2_BIT </span><span style="color: #EE5D43">|</span><span style="color: #D5CED9"> TASK3_BIT);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">xEventGroup </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xEventGroupCreate</span><span style="color: #D5CED9">();</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">vTask1Task</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #00E8C6">pvParameters</span><span style="color: #D5CED9">) {</span></span>
<span class="line"><span style="color: #D5CED9">	EventBits_t uxReturn;</span></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #C74DED">while</span><span style="color: #D5CED9">(</span><span style="color: #F39C12">1</span><span style="color: #D5CED9">) {</span></span>
<span class="line"><span style="color: #D5CED9">		uxReturn </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xEventGroupSync</span><span style="color: #D5CED9">(xEventGroup, TASK1_BIT, uxAllSyncBits, portMAX_DELAY);</span></span>
<span class="line"><span style="color: #D5CED9">		</span><span style="color: #C74DED">if</span><span style="color: #D5CED9">( uxAllSyncBits </span><span style="color: #EE5D43">==</span><span style="color: #D5CED9"> (uxReturn </span><span style="color: #EE5D43">&amp;</span><span style="color: #D5CED9"> uxAllSyncBits) ) {</span></span>
<span class="line"><span style="color: #D5CED9">			</span><span style="color: #A0A1A7CC">// Do something</span></span>
<span class="line"><span style="color: #D5CED9">		}</span></span>
<span class="line"><span style="color: #D5CED9">	}</span></span>
<span class="line"><span style="color: #D5CED9">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">vTask2Task</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #00E8C6">pvParameters</span><span style="color: #D5CED9">) {</span></span>
<span class="line"><span style="color: #D5CED9">	EventBits_t uxReturn;</span></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #C74DED">while</span><span style="color: #D5CED9">(</span><span style="color: #F39C12">1</span><span style="color: #D5CED9">) {</span></span>
<span class="line cbp-see-more-line "><span style="color: #D5CED9">		uxReturn </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xEventGroupSync</span><span style="color: #D5CED9">(xEventGroup, TASK2_BIT, uxAllSyncBits, portMAX_DELAY);</span></span>
<span class="line"><span style="color: #D5CED9">		</span><span style="color: #C74DED">if</span><span style="color: #D5CED9">( uxAllSyncBits </span><span style="color: #EE5D43">==</span><span style="color: #D5CED9"> (uxReturn </span><span style="color: #EE5D43">&amp;</span><span style="color: #D5CED9"> uxAllSyncBits) ) {</span></span>
<span class="line"><span style="color: #D5CED9">			</span><span style="color: #A0A1A7CC">// Do something</span></span>
<span class="line"><span style="color: #D5CED9">		}</span></span>
<span class="line"><span style="color: #D5CED9">	}</span></span>
<span class="line"><span style="color: #D5CED9">}</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">vTask3Task</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #00E8C6">pvParameters</span><span style="color: #D5CED9">) {</span></span>
<span class="line"><span style="color: #D5CED9">	EventBits_t uxReturn;</span></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #C74DED">while</span><span style="color: #D5CED9">(</span><span style="color: #F39C12">1</span><span style="color: #D5CED9">) {</span></span>
<span class="line"><span style="color: #D5CED9">		uxReturn </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xEventGroupSync</span><span style="color: #D5CED9">(xEventGroup, TASK3_BIT, uxAllSyncBits, portMAX_DELAY);</span></span>
<span class="line"><span style="color: #D5CED9">		</span><span style="color: #C74DED">if</span><span style="color: #D5CED9">( uxAllSyncBits </span><span style="color: #EE5D43">==</span><span style="color: #D5CED9"> (uxReturn </span><span style="color: #EE5D43">&amp;</span><span style="color: #D5CED9"> uxAllSyncBits) ) {</span></span>
<span class="line"><span style="color: #D5CED9">			</span><span style="color: #A0A1A7CC">// Do something</span></span>
<span class="line"><span style="color: #D5CED9">			</span><span style="color: #FFE66D">printf</span><span style="color: #D5CED9">(</span><span style="color: #96E072">&quot;All tasks set </span><span style="color: #EE5D43">\r\n</span><span style="color: #96E072">&quot;</span><span style="color: #D5CED9">);</span></span>
<span class="line"><span style="color: #D5CED9">			</span><span style="color: #FFE66D">vTaskDelay</span><span style="color: #D5CED9">(_200ms);</span></span>
<span class="line"><span style="color: #D5CED9">		}</span></span>
<span class="line"><span style="color: #D5CED9">	}</span></span>
<span class="line"><span style="color: #D5CED9">}                            </span></span></code></pre></div>



<br><br>
<a href="#top" style="font-size:20px; color: blue;">Back to top of the page</a>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">7579</post-id>	</item>
		<item>
		<title>STM32 FreeRTOS: Software Timers</title>
		<link>https://hangpersonal.com/2026/07/14/stm32-freertos-software-timer/</link>
		
		<dc:creator><![CDATA[hangcui1201]]></dc:creator>
		<pubDate>Tue, 14 Jul 2026 16:45:36 +0000</pubDate>
				<category><![CDATA[Embedded System]]></category>
		<guid isPermaLink="false">https://hangpersonal.com/?p=7488</guid>

					<description><![CDATA[STM32 Microcontroller and FreeRTOS Development One-shot timer: once started, it will execute its callback function once only. It can be restarted manually, but will not restart itself Auto-reload timer: once started, it will re-start itself each time it expires, resulting in periodic execution of its callback function xTimerCreate() Creates a FreeRTOS software timer using dynamically...]]></description>
										<content:encoded><![CDATA[
<a href="https://hangpersonal.com/embedded-system/stm32-mcu/freertos-tutorials/" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
STM32 Microcontroller and FreeRTOS Development
</a>
<br><br>



<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


            <div  class="spbtbl-wrapper spbtbl-blockmode spbtbl-fullwidth" >
                                <table class="spbtbl-style spbtbl-color-blue" title="FreeRTOS: Software Timer"  itemscope itemtype="http://schema.org/Table" >
                    <!-- Superb Tables Plugin -->
                    <thead>
                        <tr>
                            <th style="font-size: 18px !important;"  itemprop="name"  align="left">Software Timer API Function</th><th style="font-size: 18px !important;"  itemprop="name"  align="left">Description</th>                        </tr>
                    </thead>
                    <tbody>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#timer_create" style="font-size: 20px;color: blue">xTimerCreate()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Creates a software timer using dynamic memory</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#timer_create_static" style="font-size: 20px;color: blue">xTimerCreateStatic()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Creates a software timer using user-provided memory</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#timer_start" style="font-size: 20px;color: blue">xTimerStart()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Starts or restarts a timer from a task</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#timer_start_from_isr" style="font-size: 20px;color: blue">xTimerStartFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Starts or restarts a timer from an ISR</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#timer_stop" style="font-size: 20px;color: blue">xTimerStop()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Stops a running timer from a task</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#timer_stop_from_isr" style="font-size: 20px;color: blue">xTimerStopFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Stops a running timer from an ISR</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#timer_reset" style="font-size: 20px;color: blue">xTimerReset()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Resets a timer and restarts its period from zero</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#timer_reset_from_isr" style="font-size: 20px;color: blue">xTimerResetFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Resets a timer from an ISR</td>                            </tr>
                                            </tbody>
                </table>
                            </div>




<div class="article-text" style="margin-top:30px; margin-bottom:30px;">

<p>
<b>One-shot timer</b>: once started, it will execute its callback function once only. It can be restarted manually, but will not restart itself
</p>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img decoding="async" width="1024" height="889" src="https://hangpersonal.com/wp-content/uploads/2026/07/one-shot-timer-1024x889.png" alt="" class="wp-image-7564" style="width:650px" srcset="https://hangpersonal.com/wp-content/uploads/2026/07/one-shot-timer-1024x889.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/07/one-shot-timer-300x260.png 300w, https://hangpersonal.com/wp-content/uploads/2026/07/one-shot-timer-768x666.png 768w, https://hangpersonal.com/wp-content/uploads/2026/07/one-shot-timer-850x738.png 850w, https://hangpersonal.com/wp-content/uploads/2026/07/one-shot-timer.png 1142w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<p>
<b>Auto-reload timer</b>: once started, it will re-start itself each time it expires, resulting in periodic execution of its callback function
</p>

</div>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="686" src="https://hangpersonal.com/wp-content/uploads/2026/07/auto-reload-timer-1024x686.png" alt="" class="wp-image-7568" style="width:900px" srcset="https://hangpersonal.com/wp-content/uploads/2026/07/auto-reload-timer-1024x686.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/07/auto-reload-timer-300x201.png 300w, https://hangpersonal.com/wp-content/uploads/2026/07/auto-reload-timer-768x515.png 768w, https://hangpersonal.com/wp-content/uploads/2026/07/auto-reload-timer-850x570.png 850w, https://hangpersonal.com/wp-content/uploads/2026/07/auto-reload-timer.png 1532w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<div class="article-text" style="margin-top:50px; margin-bottom:40px;">
</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>#define configUSE_TIMERS              1 
#define configTIMER_TASK_PRIORITY     (configMAX_PRIORITIES-1) 
#define configTIMER_QUEUE_LENGTH      5
#define configTIMER_TASK_STACK_DEPTH  (configMINIMAL_STACK_SIZE*2)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configUSE_TIMERS</span><span style="color: #D5CED9">              </span><span style="color: #F39C12">1</span><span style="color: #D5CED9"> </span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configTIMER_TASK_PRIORITY</span><span style="color: #D5CED9">     (configMAX_PRIORITIES</span><span style="color: #EE5D43">-</span><span style="color: #F39C12">1</span><span style="color: #D5CED9">) </span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configTIMER_QUEUE_LENGTH</span><span style="color: #D5CED9">      </span><span style="color: #F39C12">5</span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">configTIMER_TASK_STACK_DEPTH</span><span style="color: #D5CED9">  (configMINIMAL_STACK_SIZE</span><span style="color: #EE5D43">*</span><span style="color: #F39C12">2</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="timer_create" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xTimerCreate()
</b>

<p>
Creates a FreeRTOS software timer using dynamically allocated memory from the FreeRTOS heap. It defines the timer name, period, one-shot or auto-reload mode, timer ID, and callback function. The newly created timer remains dormant until it is started.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>TimerHandle_t xTimerCreate(const char * const pcTimerName,
                           TickType_t xTimerPeriodInTicks,
                           UBaseType_t uxAutoReload,
                           void * pvTimerID,
                           TimerCallbackFunction_t pxCallbackFunction)
                           
// ---------------------- Example ----------------------

TimerHandle_t OneShotTimer_Handle;
TimerHandle_t AutoReloadTimer_Handle;

void OneShotTimerCallback(TimerHandle_t xTimer);    
void AutoReloadTimerCallback(TimerHandle_t xTimer); 

OneShotTimer_Handle = xTimerCreate("OneShotTimer",
			                     	       mainONE_SHOT_TIMER_PERIOD,
								                   pdFALSE,
								                   0,
								                   OneShotTimerCallback);
								                   
AutoReloadTimer_Handle = xTimerCreate("AutoReloadTimer",
									                    mainAUTO_RELOAD_TIMER_PERIOD,
									                    pdTRUE,
									                    0,
									                    AutoReloadTimerCallback);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">TimerHandle_t </span><span style="color: #FFE66D">xTimerCreate</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">char</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pcTimerName</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                           TickType_t </span><span style="color: #00E8C6">xTimerPeriodInTicks</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                           UBaseType_t </span><span style="color: #00E8C6">uxAutoReload</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                           </span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pvTimerID</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                           TimerCallbackFunction_t </span><span style="color: #00E8C6">pxCallbackFunction</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">                           </span></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">TimerHandle_t OneShotTimer_Handle;</span></span>
<span class="line"><span style="color: #D5CED9">TimerHandle_t AutoReloadTimer_Handle;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">OneShotTimerCallback</span><span style="color: #D5CED9">(TimerHandle_t </span><span style="color: #00E8C6">xTimer</span><span style="color: #D5CED9">);    </span></span>
<span class="line"><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">AutoReloadTimerCallback</span><span style="color: #D5CED9">(TimerHandle_t </span><span style="color: #00E8C6">xTimer</span><span style="color: #D5CED9">); </span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">OneShotTimer_Handle </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xTimerCreate</span><span style="color: #D5CED9">(</span><span style="color: #96E072">&quot;OneShotTimer&quot;</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">			                     	       mainONE_SHOT_TIMER_PERIOD,</span></span>
<span class="line"><span style="color: #D5CED9">								                   pdFALSE,</span></span>
<span class="line"><span style="color: #D5CED9">								                   </span><span style="color: #F39C12">0</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">								                   OneShotTimerCallback);</span></span>
<span class="line"><span style="color: #D5CED9">								                   </span></span>
<span class="line"><span style="color: #D5CED9">AutoReloadTimer_Handle </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xTimerCreate</span><span style="color: #D5CED9">(</span><span style="color: #96E072">&quot;AutoReloadTimer&quot;</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">									                    mainAUTO_RELOAD_TIMER_PERIOD,</span></span>
<span class="line"><span style="color: #D5CED9">									                    pdTRUE,</span></span>
<span class="line"><span style="color: #D5CED9">									                    </span><span style="color: #F39C12">0</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">									                    AutoReloadTimerCallback);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="timer_create_static" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xTimerCreateStatic()
</b>

<p>
Creates a software timer using a StaticTimer_t memory buffer supplied by the application. Unlike xTimerCreate(), it does not allocate memory from the FreeRTOS heap, making memory usage predictable and suitable for systems that avoid dynamic allocation.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>TimerHandle_t xTimerCreateStatic(const char * const pcTimerName,
                                 TickType_t xTimerPeriodInTicks,
                                 UBaseType_t uxAutoReload,
                                 void * pvTimerID,
                                 TimerCallbackFunction_t pxCallbackFunction,
                                 StaticTimer_t * pxTimerBuffer)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">TimerHandle_t </span><span style="color: #FFE66D">xTimerCreateStatic</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">char</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pcTimerName</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                 TickType_t </span><span style="color: #00E8C6">xTimerPeriodInTicks</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                 UBaseType_t </span><span style="color: #00E8C6">uxAutoReload</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                 </span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pvTimerID</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                 TimerCallbackFunction_t </span><span style="color: #00E8C6">pxCallbackFunction</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                 StaticTimer_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxTimerBuffer</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="timer_start" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xTimerStart()
</b>

<p>
Starts a previously created software timer from normal task context. After the specified timer period expires, the timer&#8217;s callback function executes. For an auto-reload timer, this repeats periodically; for a one-shot timer, it occurs only once.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xTimerStart(TimerHandle_t xTimer, 
                       TickType_t xTicksToWait)
                       
// ---------------------- Example ----------------------

TimerHandle_t OneShotTimer_Handle;
TimerHandle_t AutoReloadTimer_Handle;

xTimerStart(OneShotTimer_Handle, 0);
xTimerStart(AutoReloadTimer_Handle, 0);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xTimerStart</span><span style="color: #D5CED9">(TimerHandle_t </span><span style="color: #00E8C6">xTimer</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                       TickType_t </span><span style="color: #00E8C6">xTicksToWait</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">                       </span></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">TimerHandle_t OneShotTimer_Handle;</span></span>
<span class="line"><span style="color: #D5CED9">TimerHandle_t AutoReloadTimer_Handle;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #FFE66D">xTimerStart</span><span style="color: #D5CED9">(OneShotTimer_Handle, </span><span style="color: #F39C12">0</span><span style="color: #D5CED9">);</span></span>
<span class="line"><span style="color: #FFE66D">xTimerStart</span><span style="color: #D5CED9">(AutoReloadTimer_Handle, </span><span style="color: #F39C12">0</span><span style="color: #D5CED9">);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="timer_start_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xTimerStartFromISR()
</b>

<p>
Starts or restarts a software timer from an interrupt service routine. It sends a start command to the timer command queue and uses pxHigherPriorityTaskWoken to indicate whether a context switch should occur when the ISR exits.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xTimerStartFromISR(TimerHandle_t xTimer,
                              BaseType_t * pxHigherPriorityTaskWoken)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xTimerStartFromISR</span><span style="color: #D5CED9">(TimerHandle_t </span><span style="color: #00E8C6">xTimer</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                              BaseType_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxHigherPriorityTaskWoken</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="timer_stop" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xTimerStop()
</b>

<p>
Stops an active software timer from normal task context. Once stopped, the timer will not expire or execute its callback function, but the timer object remains valid and can be started again later.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xTimerStop(TimerHandle_t xTimer, 
                      TickType_t xTicksToWait)

// ---------------------- Example ----------------------

TimerHandle_t AutoReloadTimer_Handle;
xTimerStop(AutoReloadTimer_Handle, 0);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xTimerStop</span><span style="color: #D5CED9">(TimerHandle_t </span><span style="color: #00E8C6">xTimer</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                      TickType_t </span><span style="color: #00E8C6">xTicksToWait</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">TimerHandle_t AutoReloadTimer_Handle;</span></span>
<span class="line"><span style="color: #FFE66D">xTimerStop</span><span style="color: #D5CED9">(AutoReloadTimer_Handle, </span><span style="color: #F39C12">0</span><span style="color: #D5CED9">);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="timer_stop_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xTimerStopFromISR()
</b>

<p>
Stops an active software timer from an interrupt service routine. It is the interrupt-safe version of xTimerStop() and can request a context switch through the pxHigherPriorityTaskWoken parameter.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xTimerStopFromISR(TimerHandle_t xTimer,
                             BaseType_t * pxHigherPriorityTaskWoken)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xTimerStopFromISR</span><span style="color: #D5CED9">(TimerHandle_t </span><span style="color: #00E8C6">xTimer</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                             BaseType_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxHigherPriorityTaskWoken</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="timer_reset" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xTimerReset()
</b>

<p>
Resets a timer&#8217;s expiration time from normal task context. If the timer is active, it restarts the full timer period from the moment the reset is requested; if it is dormant, the reset operation also starts it.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xTimerReset(TimerHandle_t xTimer, 
                       TickType_t xTicksToWait)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xTimerReset</span><span style="color: #D5CED9">(TimerHandle_t </span><span style="color: #00E8C6">xTimer</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                       TickType_t </span><span style="color: #00E8C6">xTicksToWait</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="timer_reset_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xTimerResetFromISR()
</b>

<p>
Resets or starts a software timer from an interrupt service routine. It recalculates the expiration time from the moment it is called and uses pxHigherPriorityTaskWoken to indicate whether an ISR-level context switch is required.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xTimerResetFromISR(TimerHandle_t xTimer,
                              BaseType_t * pxHigherPriorityTaskWoken)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xTimerResetFromISR</span><span style="color: #D5CED9">(TimerHandle_t </span><span style="color: #00E8C6">xTimer</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                              BaseType_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxHigherPriorityTaskWoken</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<br><br>
<a href="#top" style="font-size:20px; color: blue;">Back to top of the page</a>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">7488</post-id>	</item>
		<item>
		<title>TI C2000: External Memory Interface (EMIF)</title>
		<link>https://hangpersonal.com/2026/07/01/c2000-emif/</link>
		
		<dc:creator><![CDATA[hangcui1201]]></dc:creator>
		<pubDate>Thu, 02 Jul 2026 03:42:01 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://hangpersonal.com/?p=7387</guid>

					<description><![CDATA[TI C2000 Real-Time Microcontroller: Control, Sensing, and Communication External Memory Interface (EMIF) Interfacing to SDRAM Interfacing to Asynchronous Memory EMIF Performance External Memory Interface (EMIF) This EMIF memory controller is compliant with the JESD21-C SDR SDRAM memories utilizing a 32-bit/16-bit data bus. The purpose of this EMIF is to provide a means for the CPU...]]></description>
										<content:encoded><![CDATA[
<a href="https://hangpersonal.com/embedded-system/ti-mcu/c2000-tutorials/" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
TI C2000 Real-Time Microcontroller: Control, Sensing, and Communication
</a>

<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>



<ul style="margin-top:30px; margin-bottom:30px;">

<li style="margin-bottom:16px;">
<a href="#c28x_emif" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
External Memory Interface (EMIF)
</a>
</li> 

<li style="margin-bottom:16px;">
<a href="#c28x_emif_sdram" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
Interfacing to SDRAM
</a>
</li> 

<li style="margin-bottom:16px;">
<a href="#c28x_emif_async_memory" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
Interfacing to Asynchronous Memory
</a>
</li> 

<li style="margin-bottom:16px;">
<a href="#c28x_emif_performance" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
EMIF Performance
</a>
</li> 


</ul>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="c28_emif" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
External Memory Interface (EMIF)
</b>

<p>
This EMIF memory controller is compliant with the JESD21-C SDR SDRAM memories utilizing a 32-bit/16-bit data bus. The purpose of this EMIF is to provide a means for the CPU to connect to a variety of external devices including:

<ul>
<li> Single data rate (SDR) SDRAM
</li>
<li> Asynchronous devices including NOR Flash and SRAM
</li>
</ul>

A common use for the EMIF is to interface with both a flash device and an SDRAM device simultaneously.
</p>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="772" src="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif-1024x772.png" alt="" class="wp-image-7396" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif-1024x772.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif-300x226.png 300w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif-768x579.png 768w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif-850x640.png 850w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif.png 1440w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="823" src="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_signal-1024x823.png" alt="" class="wp-image-7399" style="width:700px" srcset="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_signal-1024x823.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_signal-300x241.png 300w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_signal-768x617.png 768w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_signal-850x683.png 850w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_signal.png 1239w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="772" src="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_config-1024x772.png" alt="" class="wp-image-7402" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_config-1024x772.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_config-300x226.png 300w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_config-768x579.png 768w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_config-850x640.png 850w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_config.png 1440w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="c28x_emif_sdram" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
Interfacing to SDRAM
</b>

<p>
The EMIF supports a glueless interface to SDRAM devices with the following characteristics:
<ul>
<li> Pre-charge bit is A[10]
</li>
<li> The number of column address bits is 8, 9, 10, or 11
</li>
<li> The number of row address bits is 13, 14, 15, or 16
</li>
<li> The number of internal banks is 1, 2, or 4
</li>
</ul>
</p>

</div>



<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="603" src="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_sdram_512kpng-1024x603.png" alt="" class="wp-image-7448" style="width:600px" srcset="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_sdram_512kpng-1024x603.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_sdram_512kpng-300x177.png 300w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_sdram_512kpng-768x452.png 768w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_sdram_512kpng-850x501.png 850w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_sdram_512kpng.png 1380w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">EMIF to 512K × 16 × 2 bank SDRAM<br></figcaption></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:30px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="604" src="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_sdram_2m-1024x604.png" alt="" class="wp-image-7449" style="width:600px" srcset="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_sdram_2m-1024x604.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_sdram_2m-300x177.png 300w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_sdram_2m-768x453.png 768w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_sdram_2m-850x502.png 850w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_sdram_2m.png 1381w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">EMIF to 2M × 16 × 4 bank SDRAM</figcaption></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:30px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="331" src="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_16bit_address_pin-1024x331.png" alt="" class="wp-image-7453" style="width:900px" srcset="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_16bit_address_pin-1024x331.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_16bit_address_pin-300x97.png 300w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_16bit_address_pin-768x248.png 768w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_16bit_address_pin-1536x496.png 1536w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_16bit_address_pin-850x274.png 850w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_16bit_address_pin.png 1828w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">16-bit EMIF Address Pin Connections</figcaption></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:30px;">

<b id="c28x_emif_async_memory" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
Interfacing to Asynchronous Memory
</b>

<p>
The EMIF easily interfaces to a variety of asynchronous devices including NOR Flash and SRAM. It can be operated in two major modes
</p><ul>
<li> Normal Mode
</li>
<li> Select Strobe Mode
</li>
</ul>
<p></p>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="387" src="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_async_memory-1024x387.png" alt="" class="wp-image-7456" style="width:600px" srcset="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_async_memory-1024x387.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_async_memory-300x113.png 300w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_async_memory-768x290.png 768w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_async_memory-850x321.png 850w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_async_memory.png 1441w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:55px; margin-bottom:30px;">

<b id="c28x_emif_performance" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
EMIF Performance
</b>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="769" src="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_performance-1024x769.png" alt="" class="wp-image-7404" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_performance-1024x769.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_performance-300x225.png 300w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_performance-768x577.png 768w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_performance-850x638.png 850w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_performance.png 1440w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:30px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="878" src="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_configuration_interface-1024x878.png" alt="" class="wp-image-7462" style="width:700px" srcset="https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_configuration_interface-1024x878.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_configuration_interface-300x257.png 300w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_configuration_interface-768x659.png 768w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_configuration_interface-850x729.png 850w, https://hangpersonal.com/wp-content/uploads/2026/07/c28_emif_configuration_interface.png 1364w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">Example of Configuration Interface</figcaption></figure>
</div>


<div class="article-text" style="margin-top:60px; margin-bottom:40px;">

<b style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
Reference
</b>

<p>
[1] <a href="https://www.ti.com/video/series/c2000-f2837xd-microcontroller-one-day-workshop-series.html" style="color: blue;">
TMS320F2837xD Microcontroller Workshop</a>
</p>

</div>



<br><br>
<a href="#top" style="font-size:20px; color: blue;">Back to top of the page</a>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">7387</post-id>	</item>
		<item>
		<title>STM32 FreeRTOS: Semaphores and Mutexes</title>
		<link>https://hangpersonal.com/2026/06/28/stm32-freertos-semaphore-mutex/</link>
		
		<dc:creator><![CDATA[hangcui1201]]></dc:creator>
		<pubDate>Mon, 29 Jun 2026 05:17:29 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://hangpersonal.com/?p=7308</guid>

					<description><![CDATA[STM32 Microcontroller and FreeRTOS Development (1) The task calls xSemaphoreTake() to acquire the semaphore. Since the semaphore is unavailable, Task is placed into the Blocked state until the semaphore becomes available. (2) An interrupt occurs, and the interrupt service routine (ISR) calls xSemaphoreGiveFromISR() to give the semaphore. As a result, the semaphore becomes available. (3)...]]></description>
										<content:encoded><![CDATA[
<a href="https://hangpersonal.com/embedded-system/stm32-mcu/freertos-tutorials/" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
STM32 Microcontroller and FreeRTOS Development
</a>
<br><br>



<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


            <div  class="spbtbl-wrapper spbtbl-blockmode spbtbl-fullwidth" >
                                <table class="spbtbl-style spbtbl-color-blue" title="FreeRTOS: Semaphore and Mutex"  itemscope itemtype="http://schema.org/Table" >
                    <!-- Superb Tables Plugin -->
                    <thead>
                        <tr>
                            <th style="font-size: 18px !important;"  itemprop="name"  align="left">Semaphore &amp; Mutex API Function</th><th style="font-size: 18px !important;"  itemprop="name"  align="left">Description</th>                        </tr>
                    </thead>
                    <tbody>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#semaph_create_binary" style="font-size: 20px;color: blue">xSemaphoreCreateBinary()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Creates a dynamically allocated binary semaphore</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#semaph_create_binary_static" style="font-size: 20px;color: blue">xSemaphoreCreateBinaryStatic()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Creates a binary semaphore using user-provided memory</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#semaph_create_counting" style="font-size: 20px;color: blue">xSemaphoreCreateCounting()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Creates a counting semaphore with an initial and maximum count</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#semaph_create_counting_static" style="font-size: 20px;color: blue">xSemaphoreCreateCountingStatic()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Creates a counting semaphore using user-provided memory</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#semaph_create_mutex" style="font-size: 20px;color: blue">xSemaphoreCreateMutex()</a>
</td>                                    <td style="font-size:18px !important;" itemprop="description" >Creates a dynamically allocated mutex with priority inheritance</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#semaph_create_mutex_static" style="font-size: 20px;color: blue">xSemaphoreCreateMutexStatic()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Creates a mutex using user-provided memory</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#semaph_give" style="font-size: 20px;color: blue">xSemaphoreGive()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Releases a semaphore from a task</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#semaph_give_from_isr" style="font-size: 20px;color: blue">xSemaphoreGiveFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Releases a semaphore from an interrupt handler</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#semaph_take" style="font-size: 20px;color: blue">xSemaphoreTake()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Waits for and obtains a semaphore from a task</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#semaph_take_from_isr" style="font-size: 20px;color: blue">xSemaphoreTakeFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Obtains a semaphore from an interrupt handler without blocking</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#semaph_create_mutex_recursive" style="font-size: 20px;color: blue">xSemaphoreCreateRecursiveMutex()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Creates a mutex that the owner can lock multiple times</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#semaph_create_mutex_recursive_static" style="font-size: 20px;color: blue">xSemaphoreCreateRecursiveMutexStatic()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Creates a static recursive mutex using user-provided memory</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#semaph_take_recursive" style="font-size: 20px;color: blue">xSemaphoreTakeRecursive()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Locks a recursive mutex; the owner may lock it multiple times</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#semaph_give_recursive" style="font-size: 20px;color: blue">xSemaphoreGiveRecursive()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Unlocks a recursive mutex; call once for each successful take</td>                            </tr>
                                            </tbody>
                </table>
                            </div>




<div class="article-text" style="margin-top:30px; margin-bottom:30px;">

<p>
(1) The task calls xSemaphoreTake() to acquire the semaphore. Since the semaphore is unavailable, Task is placed into the Blocked state until the semaphore becomes available.
</p>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-full is-resized"><img loading="lazy" decoding="async" width="955" height="233" src="https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_1.png" alt="" class="wp-image-7532" style="width:500px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_1.png 955w, https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_1-300x73.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_1-768x187.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_1-850x207.png 850w" sizes="auto, (max-width: 955px) 100vw, 955px" /></figure>
</div>


<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<p>
(2) An interrupt occurs, and the interrupt service routine (ISR) calls xSemaphoreGiveFromISR() to give the semaphore. As a result, the semaphore becomes available.
</p>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="141" src="https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_2-1024x141.png" alt="" class="wp-image-7536" style="width:900px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_2-1024x141.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_2-300x41.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_2-768x106.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_2-1536x212.png 1536w, https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_2-2048x282.png 2048w, https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_2-850x117.png 850w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<p>
(3) Because the semaphore is now available, Task successfully acquires it using xSemaphoreTake(). The task transitions from the Blocked state to the Running (or Ready, depending on the scheduler) state and begins executing the associated processing.
</p>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="141" src="https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_3-1024x141.png" alt="" class="wp-image-7538" style="width:900px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_3-1024x141.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_3-300x41.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_3-768x106.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_3-1536x212.png 1536w, https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_3-2048x282.png 2048w, https://hangpersonal.com/wp-content/uploads/2026/06/binary_semph_3-850x117.png 850w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<p>
(4) Since a task function typically runs in an infinite loop, after completing the required processing it calls xSemaphoreTake() again to wait for the semaphore. Because the semaphore became unavailable after Step 3, the task enters the Blocked state once again, just as it did in Step 1. It remains blocked until another interrupt occurs and the interrupt service routine (ISR) calls xSemaphoreGiveFromISR() to give the semaphore.
</p>

</div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="semaph_create_binary" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xSemaphoreCreateBinary()
</b>

<p>
Creates a binary semaphore using memory dynamically allocated from the FreeRTOS heap. A binary semaphore has only two states: available and unavailable, internally represented by a count of 1 or 0. The semaphore is created in the unavailable/empty state, so xSemaphoreGive() must normally be called before the first successful xSemaphoreTake(). It is commonly used for task-to-task or interrupt-to-task synchronization. The function returns a semaphore handle on success or NULL if memory allocation fails.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>SemaphoreHandle_t xSemaphoreCreateBinary(void)

// ---------------------- Example ----------------------

SemaphoreHandle_t xBinarySemaphore;
xBinarySemaphore = xSemaphoreCreateBinary();
xSemaphoreGive(xBinarySemaphore);

xSemaphoreTake(xBinarySemaphore, portMAX_DELAY);
xSemaphoreGive(xBinarySemaphore);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">SemaphoreHandle_t </span><span style="color: #FFE66D">xSemaphoreCreateBinary</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">SemaphoreHandle_t xBinarySemaphore;</span></span>
<span class="line"><span style="color: #D5CED9">xBinarySemaphore </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xSemaphoreCreateBinary</span><span style="color: #D5CED9">();</span></span>
<span class="line"><span style="color: #FFE66D">xSemaphoreGive</span><span style="color: #D5CED9">(xBinarySemaphore);</span></span>
<span class="line"></span>
<span class="line"><span style="color: #FFE66D">xSemaphoreTake</span><span style="color: #D5CED9">(xBinarySemaphore, portMAX_DELAY);</span></span>
<span class="line"><span style="color: #FFE66D">xSemaphoreGive</span><span style="color: #D5CED9">(xBinarySemaphore);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="semaph_create_binary_static" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xSemaphoreCreateBinaryStatic()
</b>

<p>
Creates a binary semaphore without using the FreeRTOS heap. The application provides a StaticSemaphore_t object that stores the semaphore’s internal control information. This buffer must remain valid for the entire lifetime of the semaphore, so it should normally be global or declared with static. Like the dynamically created version, the semaphore starts empty and must be given before it can be taken. Static creation is useful in safety-critical or memory-constrained systems where dynamic allocation is undesirable.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>SemaphoreHandle_t xSemaphoreCreateBinaryStatic(StaticSemaphore_t *pxSemaphoreBuffer)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">SemaphoreHandle_t </span><span style="color: #FFE66D">xSemaphoreCreateBinaryStatic</span><span style="color: #D5CED9">(StaticSemaphore_t </span><span style="color: #EE5D43">*</span><span style="color: #00E8C6">pxSemaphoreBuffer</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="semaph_create_counting" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xSemaphoreCreateCounting()
</b>

<p>
Creates a dynamically allocated counting semaphore. uxMaxCount specifies the largest value the semaphore count can reach, while uxInitialCount specifies its starting value and must not exceed the maximum. Every successful xSemaphoreGive() increases the count, and every successful xSemaphoreTake() decreases it. Counting semaphores are commonly used either to count pending events or to manage a pool of identical resources. The function returns a valid handle on success or NULL if allocation fails.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>SemaphoreHandle_t xSemaphoreCreateCounting(UBaseType_t uxMaxCount, 
                                           UBaseType_t uxInitialCount)
                                           
// ---------------------- Example ----------------------

SemaphoreHandle_t xCountSemaphore; 
xCountSemaphore = xSemaphoreCreateCounting(255, 0);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">SemaphoreHandle_t </span><span style="color: #FFE66D">xSemaphoreCreateCounting</span><span style="color: #D5CED9">(UBaseType_t </span><span style="color: #00E8C6">uxMaxCount</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                                           UBaseType_t </span><span style="color: #00E8C6">uxInitialCount</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">                                           </span></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">SemaphoreHandle_t xCountSemaphore; </span></span>
<span class="line"><span style="color: #D5CED9">xCountSemaphore </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xSemaphoreCreateCounting</span><span style="color: #D5CED9">(</span><span style="color: #F39C12">255</span><span style="color: #D5CED9">, </span><span style="color: #F39C12">0</span><span style="color: #D5CED9">);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="semaph_create_counting_static" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xSemaphoreCreateCountingStatic()
</b>

<p>
Creates a counting semaphore using memory supplied by the application. It behaves like xSemaphoreCreateCounting(), but no FreeRTOS heap allocation is performed. The caller provides a persistent StaticSemaphore_t buffer that stores the semaphore’s control structure. The initial count must be less than or equal to the maximum count. This version is useful when all RTOS objects must have deterministic, statically allocated memory.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>SemaphoreHandle_t xSemaphoreCreateCountingStatic(UBaseType_t uxMaxCount, 
                                                 UBaseType_t uxInitialCount, 
                                                 StaticSemaphore_t * pxSemaphoreBuffer)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">SemaphoreHandle_t </span><span style="color: #FFE66D">xSemaphoreCreateCountingStatic</span><span style="color: #D5CED9">(UBaseType_t </span><span style="color: #00E8C6">uxMaxCount</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                                                 UBaseType_t </span><span style="color: #00E8C6">uxInitialCount</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                                                 StaticSemaphore_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxSemaphoreBuffer</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="semaph_create_mutex" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xSemaphoreCreateMutex()
</b>

<p>
Creates a dynamically allocated mutex for protecting a shared resource, such as a UART, SPI peripheral, file system, or shared data structure. Unlike a newly created binary semaphore, a newly created mutex starts in the available state and can immediately be taken. A mutex records which task owns it and provides priority inheritance to reduce priority-inversion problems. The task that successfully takes the mutex must be the task that gives it back. Mutexes must not be used from interrupt service routines.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>SemaphoreHandle_t xSemaphoreCreateMutex(void)

// ---------------------- Example ----------------------

SemaphoreHandle_t xMutexSemaphore;
xMutexSemaphore = xSemaphoreCreateMutex();</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">SemaphoreHandle_t </span><span style="color: #FFE66D">xSemaphoreCreateMutex</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">SemaphoreHandle_t xMutexSemaphore;</span></span>
<span class="line"><span style="color: #D5CED9">xMutexSemaphore </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xSemaphoreCreateMutex</span><span style="color: #D5CED9">();</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="semaph_create_mutex_static" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xSemaphoreCreateMutexStatic()
</b>

<p>
Creates a mutex using a user-provided StaticSemaphore_t buffer instead of dynamically allocating memory. It provides the same ownership tracking, mutual-exclusion behavior, and priority inheritance as xSemaphoreCreateMutex(). The buffer must remain allocated for as long as the mutex exists. The mutex is initially available, so no initial xSemaphoreGive() is required. This function is suitable for applications that prohibit heap allocation after startup.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>SemaphoreHandle_t xSemaphoreCreateMutexStatic(StaticSemaphore_t *pxMutexBuffer)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">SemaphoreHandle_t </span><span style="color: #FFE66D">xSemaphoreCreateMutexStatic</span><span style="color: #D5CED9">(StaticSemaphore_t </span><span style="color: #EE5D43">*</span><span style="color: #00E8C6">pxMutexBuffer</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="semaph_give" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xSemaphoreGive()
</b>

<p>
Releases a semaphore from task context. For a binary semaphore, it changes the state from unavailable to available. For a counting semaphore, it increases the current count by one, provided the maximum count has not already been reached. For a mutex, it releases ownership so another waiting task can acquire the protected resource. The function returns pdTRUE when successful and pdFALSE when the semaphore is already full or cannot be released. It must not be called from an interrupt; use xSemaphoreGiveFromISR() instead.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xSemaphoreGive(xSemaphore)

// ---------------------- Example ----------------------

xSemaphoreGive(xBinarySemaphore);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xSemaphoreGive</span><span style="color: #D5CED9">(xSemaphore)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #FFE66D">xSemaphoreGive</span><span style="color: #D5CED9">(xBinarySemaphore);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="semaph_give_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xSemaphoreGiveFromISR()
</b>

<p>
Releases a binary or counting semaphore from an interrupt service routine. If giving the semaphore unblocks a task whose priority is higher than that of the currently running task, *pxHigherPriorityTaskWoken is set to pdTRUE. The ISR should then request a context switch with the port-specific macro, commonly portYIELD_FROM_ISR(). The variable should normally be initialized to pdFALSE before the call. This function cannot be used with mutexes because mutex ownership and priority inheritance require task context.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xSemaphoreGiveFromISR(SemaphoreHandle_t xSemaphore,
                                 BaseType_t * pxHigherPriorityTaskWoken)
                                 
// ---------------------- Example ----------------------

SemaphoreHandle_t xBinarySemaphore;
xBinarySemaphore = xSemaphoreCreateBinary();

BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xSemaphoreGiveFromISR(BinarySemaphore, &amp;xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xSemaphoreGiveFromISR</span><span style="color: #D5CED9">(SemaphoreHandle_t </span><span style="color: #00E8C6">xSemaphore</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                 BaseType_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxHigherPriorityTaskWoken</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">                                 </span></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">SemaphoreHandle_t xBinarySemaphore;</span></span>
<span class="line"><span style="color: #D5CED9">xBinarySemaphore </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xSemaphoreCreateBinary</span><span style="color: #D5CED9">();</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">BaseType_t xHigherPriorityTaskWoken </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> pdFALSE;</span></span>
<span class="line"><span style="color: #FFE66D">xSemaphoreGiveFromISR</span><span style="color: #D5CED9">(BinarySemaphore, </span><span style="color: #EE5D43">&amp;</span><span style="color: #00E8C6">xHigherPriorityTaskWoken</span><span style="color: #D5CED9">);</span></span>
<span class="line"><span style="color: #FFE66D">portYIELD_FROM_ISR</span><span style="color: #D5CED9">(xHigherPriorityTaskWoken);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="semaph_take" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xSemaphoreTake()
</b>

<p>
Attempts to obtain a binary semaphore, counting semaphore, or standard mutex from task context. If the object is available, the operation succeeds immediately and its count is decreased. If it is unavailable, the calling task can enter the Blocked state for up to xTicksToWait ticks. A value of 0 performs a nonblocking check, while portMAX_DELAY can be used for an indefinite wait when the relevant FreeRTOS configuration permits it. The function returns pdTRUE when the semaphore is obtained and pdFALSE if the waiting time expires.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xSemaphoreTake(SemaphoreHandle_t xSemaphore,
                          TickType_t xBlockTime)

// ---------------------- Example ----------------------

xSemaphoreTake(xBinarySemaphore, portMAX_DELAY);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xSemaphoreTake</span><span style="color: #D5CED9">(SemaphoreHandle_t </span><span style="color: #00E8C6">xSemaphore</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                          TickType_t </span><span style="color: #00E8C6">xBlockTime</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #FFE66D">xSemaphoreTake</span><span style="color: #D5CED9">(xBinarySemaphore, portMAX_DELAY);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="semaph_take_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xSemaphoreTakeFromISR()
</b>

<p>
Attempts to obtain a binary or counting semaphore from an interrupt service routine. It cannot wait or block, so it succeeds only if the semaphore count is already greater than zero. A successful operation decreases the semaphore count and returns pdTRUE; otherwise, it returns pdFALSE. It must not be used with mutexes or recursive mutexes. In most interrupt-to-task synchronization designs, the ISR gives the semaphore and the task takes it, so this function is used less frequently than xSemaphoreGiveFromISR().
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xSemaphoreTakeFromISR(SemaphoreHandle_t xSemaphore,
                                 BaseType_t * pxHigherPriorityTaskWoken)                         </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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xSemaphoreTakeFromISR</span><span style="color: #D5CED9">(SemaphoreHandle_t </span><span style="color: #00E8C6">xSemaphore</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                 BaseType_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxHigherPriorityTaskWoken</span><span style="color: #D5CED9">)                         </span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="semaph_create_mutex_recursive" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xSemaphoreCreateRecursiveMutex()
</b>

<p>
Creates a dynamically allocated recursive mutex. A recursive mutex allows its owning task to take the same mutex multiple times without blocking itself. FreeRTOS maintains an internal recursion count that records how many times the owner has successfully taken it. The task must give the mutex exactly the same number of times before another task can acquire it. Recursive mutexes are useful when a protected function calls another function that needs the same lock. They must be used with xSemaphoreTakeRecursive() and xSemaphoreGiveRecursive(), not the standard take and give functions.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>SemaphoreHandle_t xSemaphoreCreateRecursiveMutex(void)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">SemaphoreHandle_t </span><span style="color: #FFE66D">xSemaphoreCreateRecursiveMutex</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">void</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="semaph_create_mutex_recursive_static" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xSemaphoreCreateRecursiveMutexStatic()
</b>

<p>
Creates a recursive mutex using application-provided static memory. Its behavior is identical to the dynamically created recursive mutex, including ownership tracking, priority inheritance, and recursive nesting count. The supplied StaticSemaphore_t buffer must remain valid throughout the mutex’s lifetime. This function avoids heap allocation while still allowing the same task to lock a resource repeatedly. Recursive mutex support must be enabled in FreeRTOSConfig.h.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>SemaphoreHandle_t xSemaphoreCreateRecursiveMutexStatic(StaticSemaphore_t *pxMutexBuffer)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">SemaphoreHandle_t </span><span style="color: #FFE66D">xSemaphoreCreateRecursiveMutexStatic</span><span style="color: #D5CED9">(StaticSemaphore_t </span><span style="color: #EE5D43">*</span><span style="color: #00E8C6">pxMutexBuffer</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="semaph_take_recursive" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xSemaphoreTakeRecursive()
</b>

<p>
Obtains a mutex created specifically as a recursive mutex. The first successful call assigns ownership to the calling task. Additional calls from the same task succeed immediately and increase the recursive nesting count. Calls from other tasks block for up to xTicksToWait while the mutex remains owned. The function returns pdTRUE when the mutex is obtained and pdFALSE if the waiting time expires. It must not be used with a standard mutex created by xSemaphoreCreateMutex().
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>#define xSemaphoreTakeRecursive(xMutex, xBlockTime)
  xQueueTakeMutexRecursive(xMutex, xBlockTime)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xSemaphoreTakeRecursive</span><span style="color: #D5CED9">(</span><span style="color: #00E8C6">xMutex</span><span style="color: #D5CED9">, </span><span style="color: #00E8C6">xBlockTime</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">  </span><span style="color: #FFE66D">xQueueTakeMutexRecursive</span><span style="color: #D5CED9">(xMutex, xBlockTime)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="semaph_give_recursive" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xSemaphoreGiveRecursive()
</b>

<p>
Releases one level of ownership of a recursive mutex. Each call decreases the mutex’s recursive nesting count by one. The mutex becomes available to other tasks only when the count reaches zero. Therefore, every successful call to xSemaphoreTakeRecursive() must eventually have a matching call to xSemaphoreGiveRecursive(). Only the task that owns the recursive mutex may give it, and the function must not be called from an ISR.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>#define xSemaphoreGiveRecursive(xMutex)
  xQueueGiveMutexRecursive(xMutex)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xSemaphoreGiveRecursive</span><span style="color: #D5CED9">(</span><span style="color: #00E8C6">xMutex</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">  </span><span style="color: #FFE66D">xQueueGiveMutexRecursive</span><span style="color: #D5CED9">(xMutex)</span></span></code></pre></div>



<br><br>
<a href="#top" style="font-size:20px; color: blue;">Back to top of the page</a>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">7308</post-id>	</item>
		<item>
		<title>STM32 FreeRTOS: Queues and Queue Sets</title>
		<link>https://hangpersonal.com/2026/06/28/stm32-freertos-queue/</link>
		
		<dc:creator><![CDATA[hangcui1201]]></dc:creator>
		<pubDate>Sun, 28 Jun 2026 21:43:00 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://hangpersonal.com/?p=7194</guid>

					<description><![CDATA[STM32 Microcontroller and FreeRTOS Development Queue Send &#038; Receive Queue Definition xQueueCreate() xQueueCreate() creates a queue using dynamically allocated memory from the FreeRTOS heap. It specifies the maximum number of items the queue can hold and the size of each item. The function returns a valid queue handle when creation succeeds or NULL if there...]]></description>
										<content:encoded><![CDATA[
<a href="https://hangpersonal.com/embedded-system/stm32-mcu/freertos-tutorials/" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
STM32 Microcontroller and FreeRTOS Development
</a>
<br><br>



<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


            <div  class="spbtbl-wrapper spbtbl-blockmode" >
                                <table class="spbtbl-style spbtbl-color-blue" title="FreeRTOS: Queue API Function"  itemscope itemtype="http://schema.org/Table" >
                    <!-- Superb Tables Plugin -->
                    <thead>
                        <tr>
                            <th style="font-size: 18px !important;"  itemprop="name"  align="left">Queue API Function</th><th style="font-size: 18px !important;"  itemprop="name"  align="left">Description</th>                        </tr>
                    </thead>
                    <tbody>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_create" style="font-size: 20px;color: blue">xQueueCreate()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Create a dynamic queue</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_create_static" style="font-size: 20px;color: blue">xQueueCreateStatic()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Create a static queue</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_send" style="font-size: 20px;color: blue">xQueueSend()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Add an item to the back of a queue</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_send_back" style="font-size: 20px;color: blue">xQueueSendToBack()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Add an item to the back of a queue</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_send_front" style="font-size: 20px;color: blue">xQueueSendToFront()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Add an item to the front of a queue</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_overwrite" style="font-size: 20px;color: blue">xQueueOverwrite()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Add an item to a queue, overwriting the old one if full.</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_send_from_isr" style="font-size: 20px;color: blue">xQueueSendFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Add an item to the back of a queue from ISR</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_send_back_from_isr" style="font-size: 20px;color: blue">xQueueSendToBackFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Add an item to the back of a queue from ISR</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_send_front_from_isr" style="font-size: 20px;color: blue">xQueueSendToFrontFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Add an item to the front of a queue from ISR</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_overwrite_from_isr" style="font-size: 20px;color: blue">xQueueOverwriteFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Add an item from an ISR, overwriting the old one if full.</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_receive" style="font-size: 20px;color: blue">xQueueReceive()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Receive and remove an item from a queue</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_peek" style="font-size: 20px;color: blue">xQueuePeek()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Receive an item from a queue without removing it</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_receive_from_isr" style="font-size: 20px;color: blue">xQueueReceiveFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Receive and remove an item from a queue from ISR</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_peek_from_isr" style="font-size: 20px;color: blue">xQueuePeekFromISR()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Receive an item from a queue from ISR without removing it </td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_space_available" style="font-size: 20px;color: blue">uxQueueSpacesAvailable()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Return the number of free spaces in a queue</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_msg_waiting" style="font-size: 20px;color: blue">uxQueueMessagesWaiting()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Return the number of items stored in a queue</td>                            </tr>
                                            </tbody>
                </table>
                            </div>



            <div  class="spbtbl-wrapper spbtbl-blockmode" >
                                <table class="spbtbl-style spbtbl-color-blue" title="FreeRTOS: Queue Set API Function"  itemscope itemtype="http://schema.org/Table" >
                    <!-- Superb Tables Plugin -->
                    <thead>
                        <tr>
                            <th style="font-size: 18px !important;"  itemprop="name"  align="left">Queue Set API Function</th><th style="font-size: 18px !important;"  itemprop="name"  align="left">Description</th>                        </tr>
                    </thead>
                    <tbody>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_create_set" style="font-size: 20px;color: blue">xQueueCreateSet()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Create a queue set for monitoring multiple queues or semaphores</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_add_set" style="font-size: 20px;color: blue">xQueueAddToSet()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Add a queue or semaphore to an existing queue set</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" ><a href="#queue_select_set" style="font-size: 20px;color: blue">xQueueSelectFromSet()</a></td>                                    <td style="font-size:18px !important;" itemprop="description" >Wait for and return the queue-set member that becomes ready</td>                            </tr>
                                            </tbody>
                </table>
                            </div>




<div class="article-text" style="margin-top:20px; margin-bottom:30px;">

<b id="queue_create" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:30px;">
Queue Send &#038; Receive
</b>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="165" src="https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_1-1024x165.png" alt="" class="wp-image-7359" style="width:750px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_1-1024x165.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_1-300x48.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_1-768x124.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_1-850x137.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_1.png 1059w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:50px; margin-bottom:50px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="166" src="https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_2-1024x166.png" alt="" class="wp-image-7360" style="width:750px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_2-1024x166.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_2-300x49.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_2-768x124.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_2-850x138.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_2.png 1056w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:0px;">
Queue Definition
</b>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>typedef struct QueueDefinition 
{
	int8_t *pcHead;					
	int8_t *pcWriteTo;	

	union
	{
		QueuePointers_t xQueue;		
		SemaphoreData_t xSemaphore;
	} u;

	List_t xTasksWaitingToSend;		
	List_t xTasksWaitingToReceive;	

	volatile UBaseType_t uxMessagesWaiting;
	UBaseType_t uxLength;			
	UBaseType_t uxItemSize;			

	volatile int8_t cRxLock;		
	volatile int8_t cTxLock;	

	#if( ( configSUPPORT_STATIC_ALLOCATION == 1 ) &amp;&amp; \
	     ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) )
		uint8_t ucStaticallyAllocated;
	#endif

	#if ( configUSE_QUEUE_SETS == 1 )
		struct QueueDefinition *pxQueueSetContainer;
	#endif

	#if ( configUSE_TRACE_FACILITY == 1 )
		UBaseType_t uxQueueNumber;
		uint8_t ucQueueType;
	#endif

} xQUEUE;

typedef xQUEUE Queue_t;</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #C74DED">typedef</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">struct</span><span style="color: #D5CED9"> QueueDefinition </span></span>
<span class="line"><span style="color: #D5CED9">{</span></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #C74DED">int8_t</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9">pcHead;					</span></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #C74DED">int8_t</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9">pcWriteTo;	</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #C74DED">union</span></span>
<span class="line"><span style="color: #D5CED9">	{</span></span>
<span class="line"><span style="color: #D5CED9">		QueuePointers_t xQueue;		</span></span>
<span class="line"><span style="color: #D5CED9">		SemaphoreData_t xSemaphore;</span></span>
<span class="line"><span style="color: #D5CED9">	} u;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">	List_t xTasksWaitingToSend;		</span></span>
<span class="line"><span style="color: #D5CED9">	List_t xTasksWaitingToReceive;	</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #C74DED">volatile</span><span style="color: #D5CED9"> UBaseType_t uxMessagesWaiting;</span></span>
<span class="line"><span style="color: #D5CED9">	UBaseType_t uxLength;			</span></span>
<span class="line"><span style="color: #D5CED9">	UBaseType_t uxItemSize;			</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #C74DED">volatile</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">int8_t</span><span style="color: #D5CED9"> cRxLock;		</span></span>
<span class="line cbp-see-more-line "><span style="color: #D5CED9">	</span><span style="color: #C74DED">volatile</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">int8_t</span><span style="color: #D5CED9"> cTxLock;	</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #C74DED">#if</span><span style="color: #D5CED9">( ( </span><span style="color: #FFE66D">configSUPPORT_STATIC_ALLOCATION</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">==</span><span style="color: #D5CED9"> </span><span style="color: #F39C12">1</span><span style="color: #D5CED9"> ) </span><span style="color: #EE5D43">&amp;&amp;</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">\</span></span>
<span class="line"><span style="color: #D5CED9">	     ( </span><span style="color: #FFE66D">configSUPPORT_DYNAMIC_ALLOCATION</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">==</span><span style="color: #D5CED9"> </span><span style="color: #F39C12">1</span><span style="color: #D5CED9"> ) )</span></span>
<span class="line"><span style="color: #D5CED9">		</span><span style="color: #C74DED">uint8_t</span><span style="color: #D5CED9"> ucStaticallyAllocated;</span></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #C74DED">#endif</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #C74DED">#if</span><span style="color: #D5CED9"> ( </span><span style="color: #FFE66D">configUSE_QUEUE_SETS</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">==</span><span style="color: #D5CED9"> </span><span style="color: #F39C12">1</span><span style="color: #D5CED9"> )</span></span>
<span class="line"><span style="color: #D5CED9">		</span><span style="color: #C74DED">struct</span><span style="color: #D5CED9"> QueueDefinition </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9">pxQueueSetContainer;</span></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #C74DED">#endif</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #C74DED">#if</span><span style="color: #D5CED9"> ( </span><span style="color: #FFE66D">configUSE_TRACE_FACILITY</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">==</span><span style="color: #D5CED9"> </span><span style="color: #F39C12">1</span><span style="color: #D5CED9"> )</span></span>
<span class="line"><span style="color: #D5CED9">		UBaseType_t uxQueueNumber;</span></span>
<span class="line"><span style="color: #D5CED9">		</span><span style="color: #C74DED">uint8_t</span><span style="color: #D5CED9"> ucQueueType;</span></span>
<span class="line"><span style="color: #D5CED9">	</span><span style="color: #C74DED">#endif</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">} xQUEUE;</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">typedef</span><span style="color: #D5CED9"> xQUEUE Queue_t;</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:50px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="792" height="1024" src="https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_example-1-792x1024.png" alt="" class="wp-image-7384" style="width:600px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_example-1-792x1024.png 792w, https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_example-1-232x300.png 232w, https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_example-1-768x993.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_example-1-300x388.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_example-1-850x1099.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/freertos_queue_example-1.png 1066w" sizes="auto, (max-width: 792px) 100vw, 792px" /></figure>
</div>


<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_create" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueueCreate()
</b>

<p>
xQueueCreate() creates a queue using dynamically allocated memory from the FreeRTOS heap. It specifies the maximum number of items the queue can hold and the size of each item. The function returns a valid queue handle when creation succeeds or NULL if there is insufficient heap memory.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>QueueHandle_t xQueueCreate(UBaseType_t uxQueueLength,
                           UBaseType_t uxItemSize)

// ---------------------- Example ----------------------
                           
#define MESSAGE_Q_NUM  5
QueueHandle_t msgQueue;
msgQueue = xQueueCreate(MESSAGE_Q_NUM, sizeof(uint32_t));                           </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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">QueueHandle_t </span><span style="color: #FFE66D">xQueueCreate</span><span style="color: #D5CED9">(UBaseType_t </span><span style="color: #00E8C6">uxQueueLength</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                           UBaseType_t </span><span style="color: #00E8C6">uxItemSize</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"><span style="color: #D5CED9">                           </span></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">MESSAGE_Q_NUM</span><span style="color: #D5CED9">  </span><span style="color: #F39C12">5</span></span>
<span class="line"><span style="color: #D5CED9">QueueHandle_t msgQueue;</span></span>
<span class="line"><span style="color: #D5CED9">msgQueue </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xQueueCreate</span><span style="color: #D5CED9">(MESSAGE_Q_NUM, </span><span style="color: #EE5D43">sizeof</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">uint32_t</span><span style="color: #D5CED9">));                           </span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_create_static" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueueCreateStatic()
</b>

<p>
xQueueCreateStatic() creates a queue using memory supplied by the application rather than memory allocated from the FreeRTOS heap. The application provides a storage buffer for the queue items and a StaticQueue_t structure for the queue control data. The function returns a queue handle when creation succeeds or NULL if the parameters are invalid.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>QueueHandle_t xQueueCreateStatic(UBaseType_t uxQueueLength,
                                 UBaseType_t uxItemSize,
                                 uint8_t * pucQueueStorage,
                                 StaticQueue_t * pxQueueBuffer)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">QueueHandle_t </span><span style="color: #FFE66D">xQueueCreateStatic</span><span style="color: #D5CED9">(UBaseType_t </span><span style="color: #00E8C6">uxQueueLength</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                 UBaseType_t </span><span style="color: #00E8C6">uxItemSize</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                 </span><span style="color: #C74DED">uint8_t</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pucQueueStorage</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                 StaticQueue_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxQueueBuffer</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_send" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueueSend()
</b>

<p>
xQueueSend() sends an item to the back of a FreeRTOS queue. The item is copied into the queue, and the calling task can optionally wait for available space if the queue is full. The function returns pdPASS when the item is successfully added or errQUEUE_FULL if the operation fails.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xQueueSend(QueueHandle_t xQueue,
                      const void * pvItemToQueue,
                      TickType_t xTicksToWait)
                      
// ---------------------- Example ----------------------

const TickType_t wait_time = pdMS_TO_TICKS(200);
BaseType_t qStatus = xQueueSend(msgQueue, &amp;valToSend, wait_time);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xQueueSend</span><span style="color: #D5CED9">(QueueHandle_t </span><span style="color: #00E8C6">xQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                      </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pvItemToQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                      TickType_t </span><span style="color: #00E8C6">xTicksToWait</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">                      </span></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">const</span><span style="color: #D5CED9"> TickType_t wait_time </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">pdMS_TO_TICKS</span><span style="color: #D5CED9">(</span><span style="color: #F39C12">200</span><span style="color: #D5CED9">);</span></span>
<span class="line"><span style="color: #D5CED9">BaseType_t qStatus </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xQueueSend</span><span style="color: #D5CED9">(msgQueue, </span><span style="color: #EE5D43">&amp;</span><span style="color: #00E8C6">valToSend</span><span style="color: #D5CED9">, wait_time);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_send_back" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueueSendToBack()
</b>

<p>
xQueueSendToBack() copies an item to the back of a FreeRTOS queue. If the queue is full, the calling task can wait for a specified number of ticks until space becomes available. The function returns pdPASS on success or errQUEUE_FULL if the item cannot be added.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xQueueSendToBack(QueueHandle_t xQueue,
                            const void* pvItemToQueue,
                            TickType_t xTicksToWait)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xQueueSendToBack</span><span style="color: #D5CED9">(QueueHandle_t </span><span style="color: #00E8C6">xQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                            </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">void</span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pvItemToQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                            TickType_t </span><span style="color: #00E8C6">xTicksToWait</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_send_front" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueueSendToFront()
</b>

<p>
xQueueSendToFront() copies an item to the front of a FreeRTOS queue, allowing it to be received before existing items. If the queue is full, the calling task can wait for a specified number of ticks until space becomes available. It returns pdPASS on success or errQUEUE_FULL if the item cannot be added.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xQueueSendToToFront(QueueHandle_t xQueue,
                               const void *pvItemToQueue,
                               TickType_t xTicksToWait)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xQueueSendToToFront</span><span style="color: #D5CED9">(QueueHandle_t </span><span style="color: #00E8C6">xQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                               </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #00E8C6">pvItemToQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                               TickType_t </span><span style="color: #00E8C6">xTicksToWait</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_overwrite" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueueOverwrite()
</b>

<p>
xQueueOverwrite() copies an item into a queue even when the queue is already full, replacing the existing item. It is intended for queues with a length of one, such as those storing the latest sensor value or system state. The function returns pdPASS and must not be called from an interrupt service routine.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(2 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xQueueOverwrite(QueueHandle_t xQueue,
                           const void * pvItemToQueue)
                           
// ---------------------- Example ----------------------

#define KEYMSG_Q_NUM  1
QueueHandle_t keyQueue;
keyQueue = xQueueCreate(KEYMSG_Q_NUM, sizeof(uint8_t));

uint8_t keyState = HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0);
BaseType_t qStatus = xQueueOverwrite(keyQueue, &amp;keyState);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xQueueOverwrite</span><span style="color: #D5CED9">(QueueHandle_t </span><span style="color: #00E8C6">xQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                           </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pvItemToQueue</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">                           </span></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">#define</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">KEYMSG_Q_NUM</span><span style="color: #D5CED9">  </span><span style="color: #F39C12">1</span></span>
<span class="line"><span style="color: #D5CED9">QueueHandle_t keyQueue;</span></span>
<span class="line"><span style="color: #D5CED9">keyQueue </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xQueueCreate</span><span style="color: #D5CED9">(KEYMSG_Q_NUM, </span><span style="color: #EE5D43">sizeof</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">uint8_t</span><span style="color: #D5CED9">));</span></span>
<span class="line"></span>
<span class="line"><span style="color: #C74DED">uint8_t</span><span style="color: #D5CED9"> keyState </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">HAL_GPIO_ReadPin</span><span style="color: #D5CED9">(GPIOA, GPIO_PIN_0);</span></span>
<span class="line"><span style="color: #D5CED9">BaseType_t qStatus </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xQueueOverwrite</span><span style="color: #D5CED9">(keyQueue, </span><span style="color: #EE5D43">&amp;</span><span style="color: #00E8C6">keyState</span><span style="color: #D5CED9">);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_send_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueueSendFromISR()
</b>

<p>
xQueueSendFromISR() copies an item to the back of a FreeRTOS queue from within an interrupt service routine. It does not block if the queue is full, and the pxHigherPriorityTaskWoken parameter indicates whether sending the item unblocked a higher-priority task that may require a context switch. It returns pdPASS on success or errQUEUE_FULL if the item cannot be added.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xQueueSendFromISR(QueueHandle_t xQueue,
                             const void * pvItemToQueue,
                             BaseType_t * pxHigherPriorityTaskWoken)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xQueueSendFromISR</span><span style="color: #D5CED9">(QueueHandle_t </span><span style="color: #00E8C6">xQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                             </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pvItemToQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                             BaseType_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxHigherPriorityTaskWoken</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_send_back_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueueSendToBackFromISR()
</b>

<p>
xQueueSendToBackFromISR() copies an item to the back of a FreeRTOS queue from within an interrupt service routine. It never blocks if the queue is full, and pxHigherPriorityTaskWoken indicates whether a higher-priority task was unblocked and a context switch may be required. The function returns pdPASS on success or errQUEUE_FULL if the item cannot be added.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xQueueSendToBackFromISR(QueueHandle_t xQueue,
                                   const void * pvItemToQueue,
                                   BaseType_t * pxHigherPriorityTaskWoken)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xQueueSendToBackFromISR</span><span style="color: #D5CED9">(QueueHandle_t </span><span style="color: #00E8C6">xQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                   </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pvItemToQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                   BaseType_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxHigherPriorityTaskWoken</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_send_front_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueueSendToFrontFromISR()
</b>

<p>
xQueueSendToFrontFromISR() copies an item to the front of a FreeRTOS queue from within an interrupt service routine, allowing it to be received before existing items. It does not block if the queue is full, and pxHigherPriorityTaskWoken indicates whether a higher-priority task was unblocked and a context switch may be required. The function returns pdPASS on success or errQUEUE_FULL if the item cannot be added.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xQueueSendToFrontFromISR(QueueHandle_t xQueue,
                                    const void * pvItemToQueue,
                                    BaseType_t * pxHigherPriorityTaskWoken)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xQueueSendToFrontFromISR</span><span style="color: #D5CED9">(QueueHandle_t </span><span style="color: #00E8C6">xQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                    </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pvItemToQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                    BaseType_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxHigherPriorityTaskWoken</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_overwrite_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueueOverwriteFromISR()
</b>

<p>
xQueueOverwriteFromISR() writes an item to a queue from within an interrupt service routine, replacing the existing item if the queue is already full. It is intended for queues with a length of one and never blocks. The pxHigherPriorityTaskWoken parameter indicates whether a higher-priority task was unblocked and a context switch may be required.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xQueueOverwriteFromISR(QueueHandle_t xQueue,
                                  const void * pvItemToQueue,
                                  BaseType_t * pxHigherPriorityTaskWoken)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xQueueOverwriteFromISR</span><span style="color: #D5CED9">(QueueHandle_t </span><span style="color: #00E8C6">xQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                  </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> </span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pvItemToQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                  BaseType_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxHigherPriorityTaskWoken</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_receive" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueueReceive()
</b>

<p>
xQueueReceive() removes an item from the front of a FreeRTOS queue and copies it into a user-provided buffer. If the queue is empty, the calling task can wait for a specified number of ticks until an item becomes available. The function returns pdPASS on success or errQUEUE_EMPTY if no item is received.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xQueueReceive(QueueHandle_t xQueue,
                         void * pvBuffer,
                         TickType_t xTicksToWait)
                         
// ---------------------- Example ----------------------

BaseType_t qStatus = xQueueReceive(msgQueue, &amp;valToReceive, 0);              </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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xQueueReceive</span><span style="color: #D5CED9">(QueueHandle_t </span><span style="color: #00E8C6">xQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                         </span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pvBuffer</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                         TickType_t </span><span style="color: #00E8C6">xTicksToWait</span><span style="color: #D5CED9">)</span></span>
<span class="line"><span style="color: #D5CED9">                         </span></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">BaseType_t qStatus </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xQueueReceive</span><span style="color: #D5CED9">(msgQueue, </span><span style="color: #EE5D43">&amp;</span><span style="color: #00E8C6">valToReceive</span><span style="color: #D5CED9">, </span><span style="color: #F39C12">0</span><span style="color: #D5CED9">);              </span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_peek" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueuePeek()
</b>

<p>
xQueuePeek() copies an item from the front of a FreeRTOS queue without removing it, allowing the same item to be read again later. If the queue is empty, the calling task can wait for a specified number of ticks until an item becomes available. The function returns pdPASS on success or errQUEUE_EMPTY if no item is available.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xQueuePeek(QueueHandle_t xQueue,
                      void * pvBuffer,
                      TickType_t xTicksToWait)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xQueuePeek</span><span style="color: #D5CED9">(QueueHandle_t </span><span style="color: #00E8C6">xQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                      </span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pvBuffer</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                      TickType_t </span><span style="color: #00E8C6">xTicksToWait</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_receive_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueueReceiveFromISR()
</b>

<p>
xQueueReceiveFromISR() removes an item from the front of a FreeRTOS queue and copies it into a user-provided buffer from within an interrupt service routine. It never blocks if the queue is empty, and pxHigherPriorityTaskWoken indicates whether receiving the item unblocked a higher-priority task that may require a context switch. The function returns pdPASS on success or pdFAIL if the queue is empty.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xQueueReceiveFromISR(QueueHandle_t xQueue,
                                void* pvBuffer,
                                BaseType_t * pxTaskWoken)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xQueueReceiveFromISR</span><span style="color: #D5CED9">(QueueHandle_t </span><span style="color: #00E8C6">xQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                </span><span style="color: #C74DED">void</span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pvBuffer</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                                BaseType_t </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pxTaskWoken</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_peek_from_isr" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueuePeekFromISR()
</b>

<p>
xQueuePeekFromISR() copies an item from the front of a FreeRTOS queue into a user-provided buffer from within an interrupt service routine without removing it from the queue. It never blocks if the queue is empty and returns pdPASS when an item is successfully read or pdFAIL if no item is available.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xQueuePeekFromISR(QueueHandle_t xQueue,
                             void * pvBuffer)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xQueuePeekFromISR</span><span style="color: #D5CED9">(QueueHandle_t </span><span style="color: #00E8C6">xQueue</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                             </span><span style="color: #C74DED">void</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">*</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">pvBuffer</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_space_available" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
uxQueueSpacesAvailable()
</b>

<p>
uxQueueSpacesAvailable() returns the number of free spaces currently available in a FreeRTOS queue.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>UBaseType_t uxQueueSpacesAvailable(const QueueHandle_t xQueue)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">UBaseType_t </span><span style="color: #FFE66D">uxQueueSpacesAvailable</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> QueueHandle_t </span><span style="color: #00E8C6">xQueue</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_msg_waiting" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
uxQueueMessagesWaiting()
</b>

<p>
uxQueueMessagesWaiting() returns the number of items currently stored in a FreeRTOS queue.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>UBaseType_t uxQueueMessagesWaiting(const QueueHandle_t xQueue)</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">UBaseType_t </span><span style="color: #FFE66D">uxQueueMessagesWaiting</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> QueueHandle_t </span><span style="color: #00E8C6">xQueue</span><span style="color: #D5CED9">)</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_create_set" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueueCreateSet()
</b>

<p>
xQueueCreateSet() creates a queue set that can contain multiple queues and semaphores, allowing a task to block until any member becomes ready. The length of set should be large enough to hold the total number of items that all member queues and semaphores may contain.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>QueueSetHandle_t xQueueCreateSet(const UBaseType_t uxEventQueueLength)

// ---------------------- Example ----------------------

QueueSetHandle_t xQueueSet = NULL;
QueueHandle_t xQueue1 = NULL, xQueue2 = NULL;
xQueue1 = xQueueCreate(1, sizeof(char*));
xQueue2 = xQueueCreate(1, sizeof(char*));
xQueueSet = xQueueCreateSet(1*2);</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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">QueueSetHandle_t </span><span style="color: #FFE66D">xQueueCreateSet</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> UBaseType_t </span><span style="color: #00E8C6">uxEventQueueLength</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">QueueSetHandle_t xQueueSet </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">NULL</span><span style="color: #D5CED9">;</span></span>
<span class="line"><span style="color: #D5CED9">QueueHandle_t xQueue1 </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">NULL</span><span style="color: #D5CED9">, xQueue2 </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #EE5D43">NULL</span><span style="color: #D5CED9">;</span></span>
<span class="line"><span style="color: #D5CED9">xQueue1 </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xQueueCreate</span><span style="color: #D5CED9">(</span><span style="color: #F39C12">1</span><span style="color: #D5CED9">, </span><span style="color: #EE5D43">sizeof</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">char</span><span style="color: #EE5D43">*</span><span style="color: #D5CED9">));</span></span>
<span class="line"><span style="color: #D5CED9">xQueue2 </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xQueueCreate</span><span style="color: #D5CED9">(</span><span style="color: #F39C12">1</span><span style="color: #D5CED9">, </span><span style="color: #EE5D43">sizeof</span><span style="color: #D5CED9">(</span><span style="color: #C74DED">char</span><span style="color: #EE5D43">*</span><span style="color: #D5CED9">));</span></span>
<span class="line"><span style="color: #D5CED9">xQueueSet </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span><span style="color: #FFE66D">xQueueCreateSet</span><span style="color: #D5CED9">(</span><span style="color: #F39C12">1</span><span style="color: #EE5D43">*</span><span style="color: #F39C12">2</span><span style="color: #D5CED9">);</span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_add_set" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueueAddToSet()
</b>

<p>
xQueueAddToSet() adds a queue, semaphore, or mutex to an existing queue set so a task can monitor it together with other set members. The member should be empty when added, and the function returns pdPASS if successful or pdFAIL if it cannot be added.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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 xQueueAddToSet(QueueSetMemberHandle_t xQueueOrSemaphore,
                          QueueSetHandle_t xQueueSet)

// ---------------------- Example ----------------------

xQueueAddToSet(xQueue1, xQueueSet);
xQueueAddToSet(xQueue2, xQueueSet);                          </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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">BaseType_t </span><span style="color: #FFE66D">xQueueAddToSet</span><span style="color: #D5CED9">(QueueSetMemberHandle_t </span><span style="color: #00E8C6">xQueueOrSemaphore</span><span style="color: #D5CED9">,</span></span>
<span class="line"><span style="color: #D5CED9">                          QueueSetHandle_t </span><span style="color: #00E8C6">xQueueSet</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #FFE66D">xQueueAddToSet</span><span style="color: #D5CED9">(xQueue1, xQueueSet);</span></span>
<span class="line"><span style="color: #FFE66D">xQueueAddToSet</span><span style="color: #D5CED9">(xQueue2, xQueueSet);                          </span></span></code></pre></div>



<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="queue_select_set" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
xQueueSelectFromSet()
</b>

<p>
xQueueSelectFromSet() blocks for a specified time until a queue or semaphore in a queue set becomes ready, then returns the handle of the ready member. A return value of NULL indicates that the timeout expired before any member became available.
</p>

</div>



<div class="wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers" data-code-block-pro-font-family="Code-Pro-JetBrains-Mono" style="font-size:1rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D5CED9;--cbp-line-number-width:calc(1 * 0.6 * 1rem);line-height:1.5rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)"><span role="button" tabindex="0" style="color:#D5CED9;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>QueueSetMemberHandle_t xQueueSelectFromSet(QueueSetHandle_t xQueueSet, 
                                           TickType_t const xTicksToWait)

// ---------------------- Example ----------------------

QueueHandle_t xQueueThatContainsData;
xQueueThatContainsData = 
    (QueueHandle_t)xQueueSelectFromSet(xQueueSet, portMAX_DELAY);                                           </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="M4.5 12.75l6 6 9-13.5"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6"></path></svg></span><pre class="shiki andromeda" style="background-color: #23262E" tabindex="0"><code><span class="line"><span style="color: #D5CED9">QueueSetMemberHandle_t </span><span style="color: #FFE66D">xQueueSelectFromSet</span><span style="color: #D5CED9">(QueueSetHandle_t </span><span style="color: #00E8C6">xQueueSet</span><span style="color: #D5CED9">, </span></span>
<span class="line"><span style="color: #D5CED9">                                           TickType_t </span><span style="color: #C74DED">const</span><span style="color: #D5CED9"> </span><span style="color: #00E8C6">xTicksToWait</span><span style="color: #D5CED9">)</span></span>
<span class="line"></span>
<span class="line"><span style="color: #A0A1A7CC">// ---------------------- Example ----------------------</span></span>
<span class="line"></span>
<span class="line"><span style="color: #D5CED9">QueueHandle_t xQueueThatContainsData;</span></span>
<span class="line"><span style="color: #D5CED9">xQueueThatContainsData </span><span style="color: #EE5D43">=</span><span style="color: #D5CED9"> </span></span>
<span class="line"><span style="color: #D5CED9">    (QueueHandle_t)</span><span style="color: #FFE66D">xQueueSelectFromSet</span><span style="color: #D5CED9">(xQueueSet, portMAX_DELAY);                                           </span></span></code></pre></div>



<br><br>
<a href="#top" style="font-size:20px; color: blue;">Back to top of the page</a>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">7194</post-id>	</item>
		<item>
		<title>TI C2000: Hardware Acceleration Subsystem &#8211; Control Law Accelerator (CLA)</title>
		<link>https://hangpersonal.com/2026/06/27/c2000-cla/</link>
		
		<dc:creator><![CDATA[hangcui1201]]></dc:creator>
		<pubDate>Sun, 28 Jun 2026 04:07:15 +0000</pubDate>
				<category><![CDATA[Uncategorized]]></category>
		<guid isPermaLink="false">https://hangpersonal.com/?p=7168</guid>

					<description><![CDATA[TI C2000 Real-Time Microcontroller: Control, Sensing, and Communication Control Law Accelerator (CLA) CLA Memory and Register Access CLA Tasks CLA Registers CLA Initialization CLA Task Programming CLA C Language Implementation and Restrictions CLA Assembly Language Implementation CLA Code Debugging Control Law Accelerator (CLA) The CLA is an independent, fully programmable, 32-bit floating-point math processor. It...]]></description>
										<content:encoded><![CDATA[
<a href="https://hangpersonal.com/embedded-system/ti-mcu/c2000-tutorials/" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
TI C2000 Real-Time Microcontroller: Control, Sensing, and Communication
</a>



<ul style="margin-top:30px; margin-bottom:30px;">

<li style="margin-bottom:16px;">
<a href="#c28x_cla" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
Control Law Accelerator (CLA)
</a>
</li> 

<li style="margin-bottom:16px;">
<a href="#c28_cla_memory_register" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
CLA Memory and Register Access
</a>
</li> 

<li style="margin-bottom:16px;">
<a href="#c28_cla_task" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
CLA Tasks
</a>
</li> 

<li style="margin-bottom:16px;">
<a href="#c28_cla_register" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
CLA Registers
</a>
</li> 

<li style="margin-bottom:16px;">
<a href="#c28_cla_init" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
CLA Initialization
</a>
</li> 

<li style="margin-bottom:16px;">
<a href="#c28_cla_task_programming" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
CLA Task Programming
</a>
</li> 

<li style="margin-bottom:16px;">
<a href="#c28_cla_c_language" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
CLA C Language Implementation and Restrictions
</a>
</li> 

<li style="margin-bottom:16px;">
<a href="#c28_cla_assembly" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
CLA Assembly Language Implementation
</a>
</li> 

<li style="margin-bottom:16px;">
<a href="#c28_cla_debug" style="font-family: 'Inter', sans-serif; font-size: 22px; color: blue;">
CLA Code Debugging
</a>
</li> 

</ul>



<div class="article-text" style="margin-top:50px; margin-bottom:40px;">

<b id="c28_cla" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
Control Law Accelerator (CLA)
</b>

<p>
The CLA is an independent, fully programmable, 32-bit floating-point math processor. It executes algorithms independently and in parallel with the CPU. This extends the capabilities of the C28x CPU by adding parallel processing. The CLA has direct access to the ADC result registers. Additionally, the CLA has access to all ePWM, high-resolution PWM, eCAP, eQEP, CMPSS, DAC, SDFM, SPI, McBSP, uPP and GPIO data registers. This allows the CLA to read ADC samples just-intime and significantly reduces the ADC sample to output delay enabling faster system response and higher frequency operation. The CLA responds to peripheral interrupts independently of the CPU. Utilizing the CLA for time-critical tasks frees up the CPU to perform other system, diagnostics, and communication functions concurrently.
</p>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="710" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla-1024x710.png" alt="" class="wp-image-7203" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla-1024x710.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla-300x208.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla-768x533.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla-850x590.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla.png 1440w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="732" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_block-1024x732.png" alt="" class="wp-image-7205" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_block-1024x732.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_block-300x215.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_block-768x549.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_block-850x608.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_block.png 1440w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:50px; margin-bottom:40px;">

<b id="c28_cla_memory_register" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
CLA Memory and Register Access
</b>

<p>
The CLA has access to the LSx RAM blocks and each memory block can be configured to be either dedicated to the CPU or shared between the CPU and CLA. After reset the memory block is mapped to the CPU, where it can be initialized by the CPU before being shared with the CLA. Once it is shared between the CPU and CLA it then can be configured to be either program memory or data memory. When configured as program memory it contains the CLA program code, and when configured as data memory it contains the variable and coefficients that are used by the CLA program code. Additionally, dedicated message RAMs are used to pass data
between the CPU and CLA, and CLA and CPU.
</p>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="771" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_memory_register-1024x771.png" alt="" class="wp-image-7208" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_memory_register-1024x771.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_memory_register-300x226.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_memory_register-768x578.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_memory_register-850x640.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_memory_register.png 1335w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:50px; margin-bottom:40px;">

<b id="c28_cla_task" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
CLA Tasks
</b>

<p>
Programming the CLA consists of initialization code, which is performed by the CPU, and tasks. A task is similar to an interrupt service routine, and once started it runs to completion. Tasks can be written in C or assembly code, where typically the user will use assembly code for high performance time-critical tasks, and C for non-critical tasks. Each task is capable of being triggered by a variety of peripherals without CPU intervention, which makes the CLA very efficient since it does not use interrupts for hardware synchronization, nor must the CLA do any context switching. Unlike the traditional interrupt-based scheme, the CLA approach becomes deterministic. The CLA supports eight independent tasks and each is mapped back to an event
trigger. Since the CLA is a software programmable accelerator, it is very flexible and can be modified for different applications.
</p>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="771" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task-1024x771.png" alt="" class="wp-image-7211" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task-1024x771.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task-300x226.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task-768x578.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task-850x640.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task.png 1335w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="773" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_software_trigger-1024x773.png" alt="" class="wp-image-7213" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_software_trigger-1024x773.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_software_trigger-300x227.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_software_trigger-768x580.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_software_trigger-850x642.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_software_trigger.png 1336w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="c28_cla_ctrl_exec_register" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:0px;">
CLA Control and Execution Registers
</b>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="769" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_exec_register-1024x769.png" alt="" class="wp-image-7217" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_exec_register-1024x769.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_exec_register-300x225.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_exec_register-768x577.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_exec_register-850x639.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_exec_register.png 1339w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="c28_cla_register" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:0px;">
CLA Registers
</b>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="793" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_register-1024x793.png" alt="" class="wp-image-7221" style="width:700px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_register-1024x793.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_register-300x232.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_register-768x595.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_register-850x658.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_register.png 1143w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="684" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_register-1024x684.png" alt="" class="wp-image-7223" style="width:700px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_register-1024x684.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_register-300x200.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_register-768x513.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_register-850x568.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_register.png 1241w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="769" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_exec_register-1-1024x769.png" alt="" class="wp-image-7225" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_exec_register-1-1024x769.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_exec_register-1-300x225.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_exec_register-1-768x577.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_exec_register-1-850x639.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_ctrl_exec_register-1.png 1339w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="773" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_source_selection_register-1024x773.png" alt="" class="wp-image-7227" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_source_selection_register-1024x773.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_source_selection_register-300x227.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_source_selection_register-768x580.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_source_selection_register-850x642.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_source_selection_register.png 1336w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="827" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_interrupt_trigger_source-1024x827.png" alt="" class="wp-image-7229" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_interrupt_trigger_source-1024x827.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_interrupt_trigger_source-300x242.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_interrupt_trigger_source-768x620.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_interrupt_trigger_source-850x686.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_task_interrupt_trigger_source.png 1225w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="674" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_interrupt_enable_register-1024x674.png" alt="" class="wp-image-7232" style="width:750px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_interrupt_enable_register-1024x674.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_interrupt_enable_register-300x197.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_interrupt_enable_register-768x505.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_interrupt_enable_register-350x230.png 350w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_interrupt_enable_register-850x559.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_interrupt_enable_register.png 1306w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="c28_cla_init" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
CLA Initialization
</b>

<p>
Set the Specify CLA support project option to <b>cla1</b>
</p>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="770" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_init-1024x770.png" alt="" class="wp-image-7236" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_init-1024x770.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_init-300x226.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_init-768x578.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_init-850x639.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_init.png 1336w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="c28_cla_task_programming" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
CLA Task Programming
</b>

<p>
</p><ul>

<li> Can be written in C or assembly code
</li>

<li> Assembly code will give best performance for time-critical tasks
</li>

<li> Writing in assembly may not be so bad
<ul>
<li> CLA programs in floating point
</li>
<li> Often not that much code in a task
</li>
</ul>
</li>

<li> The user will use assembly for critical tasks, and C for non-critical tasks
</li>

</ul>
<p></p>

</div>



<div class="article-text" style="margin-top:40px; margin-bottom:30px;">

<b id="c28_cla_c_language" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
CLA C Language Implementation and Restrictions
</b>


</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="775" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_language-1024x775.png" alt="" class="wp-image-7246" style="width:750px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_language-1024x775.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_language-300x227.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_language-768x581.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_language-850x643.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_language.png 1256w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="739" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_restriction_1-1024x739.png" alt="" class="wp-image-7248" style="width:750px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_restriction_1-1024x739.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_restriction_1-300x216.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_restriction_1-768x554.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_restriction_1-850x613.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_restriction_1.png 1339w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="710" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_restriction_2-1024x710.png" alt="" class="wp-image-7249" style="width:750px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_restriction_2-1024x710.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_restriction_2-300x208.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_restriction_2-768x532.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_restriction_2-850x589.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_restriction_2.png 1336w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


            <div  class="spbtbl-wrapper spbtbl-blockmode" >
                                <table class="spbtbl-style spbtbl-color-blue" title="CLAmath"  itemscope itemtype="http://schema.org/Table" >
                    <!-- Superb Tables Plugin -->
                    <thead>
                        <tr>
                            <th style="font-size: 18px !important;"  itemprop="name"  align="left"></th><th style="font-size: 18px !important;"  itemprop="name"  align="left"></th><th style="font-size: 18px !important;"  itemprop="name"  align="left"></th><th style="font-size: 18px !important;"  itemprop="name"  align="left"></th>                        </tr>
                    </thead>
                    <tbody>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >acos</td>                                    <td style="font-size:18px !important;" itemprop="description" >asin</td>                                    <td style="font-size:18px !important;" itemprop="description" >atan</td>                                    <td style="font-size:18px !important;" itemprop="description" >atan2</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >atan2PU</td>                                    <td style="font-size:18px !important;" itemprop="description" >cos</td>                                    <td style="font-size:18px !important;" itemprop="description" >cosPU</td>                                    <td style="font-size:18px !important;" itemprop="description" >div</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >exp</td>                                    <td style="font-size:18px !important;" itemprop="description" >exp10</td>                                    <td style="font-size:18px !important;" itemprop="description" >exp2</td>                                    <td style="font-size:18px !important;" itemprop="description" >expN</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >isqrt</td>                                    <td style="font-size:18px !important;" itemprop="description" >In</td>                                    <td style="font-size:18px !important;" itemprop="description" >log10</td>                                    <td style="font-size:18px !important;" itemprop="description" >logN</td>                            </tr>
                        <tr>                                    <td style="font-size:18px !important;" itemprop="description" >sin</td>                                    <td style="font-size:18px !important;" itemprop="description" >sinPU</td>                                    <td style="font-size:18px !important;" itemprop="description" >sincos</td>                                    <td style="font-size:18px !important;" itemprop="description" >sqrt</td>                            </tr>
                                            </tbody>
                </table>
                            </div>



<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="718" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_compiler_scratchpad-1024x718.png" alt="" class="wp-image-7253" style="width:700px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_compiler_scratchpad-1024x718.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_compiler_scratchpad-300x210.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_compiler_scratchpad-768x538.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_compiler_scratchpad-850x596.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_compiler_scratchpad.png 1290w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="770" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_example-1024x770.png" alt="" class="wp-image-7257" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_example-1024x770.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_example-300x226.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_example-768x578.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_example-850x639.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_c_example.png 1336w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:40px; margin-bottom:30px;">

<b id="c28_cla_assembly" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
CLA Assembly Language Implementation
</b>


</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="793" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly-1024x793.png" alt="" class="wp-image-7261" style="width:700px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly-1024x793.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly-300x232.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly-768x595.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly-850x658.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly.png 1183w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="771" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_instruction-1024x771.png" alt="" class="wp-image-7263" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_instruction-1024x771.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_instruction-300x226.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_instruction-768x578.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_instruction-850x640.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_instruction.png 1336w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="771" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_parallel_instruction-1024x771.png" alt="" class="wp-image-7265" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_parallel_instruction-1024x771.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_parallel_instruction-300x226.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_parallel_instruction-768x578.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_parallel_instruction-850x640.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_parallel_instruction.png 1336w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="773" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_address_modes-1024x773.png" alt="" class="wp-image-7267" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_address_modes-1024x773.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_address_modes-300x226.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_address_modes-768x579.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_address_modes-850x641.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_address_modes.png 1336w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="769" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_example-1024x769.png" alt="" class="wp-image-7269" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_example-1024x769.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_example-300x225.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_example-768x576.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_example-850x638.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_assembly_example.png 1339w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:30px; margin-bottom:40px;">
</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="773" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_init_example-1024x773.png" alt="" class="wp-image-7271" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_init_example-1024x773.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_init_example-300x226.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_init_example-768x579.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_init_example-850x641.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_init_example.png 1336w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:50px; margin-bottom:30px;">

<b id="c28_cla_debug" style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:0px;">
CLA Code Debugging
</b>

</div>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" width="1024" height="773" src="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_code_debug-1024x773.png" alt="" class="wp-image-7274" style="width:800px" srcset="https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_code_debug-1024x773.png 1024w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_code_debug-300x227.png 300w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_code_debug-768x580.png 768w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_code_debug-850x642.png 850w, https://hangpersonal.com/wp-content/uploads/2026/06/c28_cla_code_debug.png 1336w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<div class="article-text" style="margin-top:60px; margin-bottom:40px;">

<b style="display:block;
          font-family: 'Inter', sans-serif; 
          font-size: 22px; 
          color: black; 
          margin-top:0px; 
          margin-bottom:20px;">
Reference
</b>

<p>
[1] <a href="https://www.ti.com/video/series/c2000-f2837xd-microcontroller-one-day-workshop-series.html" style="color: blue;">
TMS320F2837xD Microcontroller Workshop</a>
</p>

</div>



<br><br>
<a href="#top" style="font-size:20px; color: blue;">Back to top of the page</a>



<p class="wp-block-paragraph"></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">7168</post-id>	</item>
	</channel>
</rss>
