Skip to main content
Associate III
April 6, 2025
Solved

H743 FreeRTOS

  • April 6, 2025
  • 3 replies
  • 911 views

HI I m using H743 Nucleo, to write a RTOS program with 2 tasks which gonna access to the same memory location concurrently.. can anyone advise which  RTOS method to use ? Tasks ? Semaphore? Message Queue? 

Best answer by mƎALLEm

@HMSEdinburge wrote:

How to acheive concurrent if use mutex? doesn't mutex mean exclude 1 task from another?


If you are not familiar with RTOSes, I suggest you to learn about it.

and especially mutexes: see that video: https://www.youtube.com/watch?app=desktop&v=I55auRpbiTs&t=0s

 

"not concurrent but simultaneously... in this case, could the 2 tasks access to the same memory location"

Nothing is done simultaneously in RTOS. As I said,  with RTOS only one instruction is executed at a time. The RTOS scheduler makes the tasks seem to be executed in parallel.

 


@HMSEdinburge wrote:

How to acheive concurrent if use mutex? doesn't mutex mean exclude 1 task from another?


That doesn't have a specific relation with STM32.

3 replies

AScha.3
Super User
April 6, 2025

Hi,

Depends on what you want:

- just use it on both tasks: make a global volatile variable 

- have some control, when a task is allowed to use it: use a semaphore 

 

Don't forget, you are on a single core here, so it's never really concurrent in many tasks, it's always only one task running for some milliseconds, then the other or next.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Associate III
April 6, 2025

ok agree, not concurrent but simultaneously... in this case, could the 2 tasks access to the same memory location (where ext. input data from ADC are stored)

AScha.3
Super User
April 6, 2025

Right, problem solved. 

-> use global volatile variable.

"If you feel a post has answered your question, please click ""Accept as Solution""."
mƎALLEm
Technical Moderator
April 6, 2025

Hello,

What do you mean by "access to the same memory location concurrently"?

Even with RTOS only one instruction is executed at a time. The RTOS scheduler makes the tasks seem to be executed in parallel.

STM32H743 MCU is a single core product. There is no worry about the HW concurrence to a memory.

Now if you are talking about mutual exclusion on a specific variable, structure etc, this is another thing.. You need to manage it with mutex or semaphore ...

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Associate III
April 6, 2025

How to acheive concurrent if use mutex? doesn't mutex mean exclude 1 task from another?

mƎALLEm
mƎALLEmAnswer
Technical Moderator
April 6, 2025

@HMSEdinburge wrote:

How to acheive concurrent if use mutex? doesn't mutex mean exclude 1 task from another?


If you are not familiar with RTOSes, I suggest you to learn about it.

and especially mutexes: see that video: https://www.youtube.com/watch?app=desktop&v=I55auRpbiTs&t=0s

 

"not concurrent but simultaneously... in this case, could the 2 tasks access to the same memory location"

Nothing is done simultaneously in RTOS. As I said,  with RTOS only one instruction is executed at a time. The RTOS scheduler makes the tasks seem to be executed in parallel.

 


@HMSEdinburge wrote:

How to acheive concurrent if use mutex? doesn't mutex mean exclude 1 task from another?


That doesn't have a specific relation with STM32.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Andrew Neil
Super User
April 6, 2025

Sounds like what you really need is a tutorial on FreeRTOS (maybe RTOS in general) - none of this is specific to STM32.

https://www.freertos.org/Documentation/01-FreeRTOS-quick-start/01-Beginners-guide/00-Overview

https://www.freertos.org/Documentation/00-Overview 

https://www.freertos.org/Community 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.