Skip to main content
Visitor
Solved

STM32F722ZE: Guidance on Firmware Architecture for a Multi-Sensor Scientific Payload

Hello everyone,

I am a student member of Team VITAKSH at VIT Bhopal University, India. We are developing a scientific payload called OSAD (Open Spectral Atmosphere Dataset) for a high-altitude balloon mission.

Our objective is to measure solar spectral variations at different altitudes and correlate them with atmospheric and environmental parameters.

We have procured the STM32 NUCLEO-F722ZE and are beginning firmware development. Before integrating all our sensors, we want to establish a reliable firmware architecture rather than simply implementing each sensor independently.

Our payload involves multiple sensors communicating over I²C, SPI and UART. We expect to acquire measurements periodically, timestamp them, process the incoming data and store them reliably for post-flight analysis.

We are currently trying to understand a few architectural decisions:

1. Firmware structure: What would be a good way to organise a multi-sensor acquisition system using STM32CubeIDE and HAL? Would a modular, interrupt-driven architecture be a suitable starting point?

2. Timers and DMA: How should we approach periodic sensor acquisition using hardware timers? Where would DMA provide a meaningful advantage over interrupt-based or polling methods, particularly for SPI and UART communication?

3. Data handling: What would be a reliable approach to buffering, timestamping and transferring sensor data to external memory without losing samples?

4. Reliability: What practices should we follow for peripheral error handling, communication timeouts, sensor failures and recovery?

We are not trying to build a complicated RTOS-based system immediately. We would prefer to understand the fundamentals and establish a clean, maintainable bare-metal architecture first, while keeping future expansion in mind.

We would particularly appreciate recommendations for relevant STM32CubeF7 examples, application notes or reference projects that demonstrate these approaches.

We are students learning through an actual engineering project, so practical suggestions and lessons from real STM32 applications would be extremely valuable to us.

Thank you for your time!

mƎALLEm
mƎALLEmBest answer
ST Technical Moderator

One thing we'd like to understand: would you recommend developing and testing the peripheral drivers independently using STM32 HAL first, and then integrating FreeRTOS, or starting with FreeRTOS from the beginning?

You need to start to develop code snippets test for each module. Need to validate each function.

Then create a FreeRTOS based project and start to add modules one by one and validate. For each step you need to ensure you didn’t create any regression.

Also, are there any STM32CubeF7 examples or reference projects you would recommend for learning how to combine FreeRTOS, DMA and interrupt-driven peripheral communication effectively?

Not exactly the same. You can start by playing with the CubeF7 package: https://github.com/STMicroelectronics/STM32CubeF7/tree/master/Projects planty examples are available. 

For FreeRTOS you can refer to these examples:

https://github.com/STMicroelectronics/STM32CubeF7/tree/master/Projects/STM32F722ZE-Nucleo/Applications/FreeRTOS

I’m sure there are many YouTube videos showing how to create a project with STM32 and FreeRTOS.

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

5 replies

mƎALLEm
ST Technical Moderator

Hello ​@RIK137 and welcome to the ST community,

Regarding this statement: 

We are not trying to build a complicated RTOS-based system immediately. We would prefer to understand the fundamentals and establish a clean, maintainable bare-metal architecture first, while keeping future expansion in mind.

Bare-metal is not well suitable for “future expansion”. More you plan to integrate modules in your application in the future more its development becomes more complex and to maintain the old functionality without regressions. The timing will be more complex to manage. So better to opt for a RTOS if you plan to add modules in the future.

I invite you to read this article by Jacob Beningo: 

https://www.beningo.com/how-to-choose-between-bare-metal-rtos-and-gpos/

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
RIK137Author
Visitor

Thank you for the recommendation and the reference article!

I understand your point about the increasing complexity of bare-metal development as the system expands. We are now considering FreeRTOS for our payload.

One thing we'd like to understand: would you recommend developing and testing the peripheral drivers independently using STM32 HAL first, and then integrating FreeRTOS, or starting with FreeRTOS from the beginning?

Also, are there any STM32CubeF7 examples or reference projects you would recommend for learning how to combine FreeRTOS, DMA and interrupt-driven peripheral communication effectively?

We would really appreciate your guidance. Thank you!

mƎALLEm
mƎALLEmBest answer
ST Technical Moderator

One thing we'd like to understand: would you recommend developing and testing the peripheral drivers independently using STM32 HAL first, and then integrating FreeRTOS, or starting with FreeRTOS from the beginning?

You need to start to develop code snippets test for each module. Need to validate each function.

Then create a FreeRTOS based project and start to add modules one by one and validate. For each step you need to ensure you didn’t create any regression.

Also, are there any STM32CubeF7 examples or reference projects you would recommend for learning how to combine FreeRTOS, DMA and interrupt-driven peripheral communication effectively?

Not exactly the same. You can start by playing with the CubeF7 package: https://github.com/STMicroelectronics/STM32CubeF7/tree/master/Projects planty examples are available. 

For FreeRTOS you can refer to these examples:

https://github.com/STMicroelectronics/STM32CubeF7/tree/master/Projects/STM32F722ZE-Nucleo/Applications/FreeRTOS

I’m sure there are many YouTube videos showing how to create a project with STM32 and FreeRTOS.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Pavel A.

Your mentors in the University should be happy to discuss and advice the app (software + hardware) architecture with you.

In embedded, the software and hardware aspects often are tightly connected. For example (just guessing) measurements may require maintenance of temperature and humidity of the sensors (heat or cool them, defrost, compensate for pressure, vibration, interact with other modules to share power, etc.)

Of course the students are required to develop the code themselves, but think of this like about other fundamentals: you will write the code in C or other programming language, but you are not required to reinvent a compiler. You will use some math, but not required to reinvent this math. The same with the architecture.

RTOS or “super-loop” is a bunch of issues by itself. Requirement to use a specific RTOS may come from the upper project level, or they may give you the whole MCU to manage as you like to.

Entirely agree with ​@mƎALLEm on reference to Jakob Beningo. The [unit] test-driven approach also is promoted by Beningo. Though that’s a lot of reading.

Good luck!

 

Explorer

Hello RIK137, and good luck with the payload — building on the advice above, one pattern that has worked well for me on multi-sensor projects is to keep acquisition, buffering and storage separate. Give every sensor a small driver with the same shape — init, read and deinit — returning a timestamped sample in a common structure, rather than letting each sensor write straight to the SD card or UART. Put those samples in a queue or ring buffer, then let a separate logging task drain it. That way a slow SD write cannot block the next sensor read, and a single slow or failing sensor does not hold up the rest. Keep interrupt handlers short and use DMA where you can for SPI and UART transfers. Add timeouts and sanity checks on each read, and log a fault code with the timestamp instead of silently dropping the sample. Get one sensor working end to end — read, timestamp, queue and log — before adding the next, as the moderator suggested. It makes faults much easier to trace in the flight data later. Starting with that structure in bare metal should also make a later move to FreeRTOS easier, since each sensor task and the logging task already have clear boundaries.