Description
Description
This course focuses on programming microcontrollers, particularly Cortex-M-based MCUs, using the C language. Participants will gain hands-on experience with bare-metal programming on an STM32F4 MCU (Cortex-M4 core) while understanding toolchains, debugging techniques, and performance optimization.
Training Objectives
- Review the C language standard with an emphasis on embedded applications.
- Identify essential C features for embedded systems.
- Explore the embedded context through practical labs on STM32F4 MCUs.
- Utilize debugging tools effectively.
- Understand the toolchain process
- including compilation
- assembly
- and linking.
- Configure linker scripts for memory management.
- Gain an overview of STM32F4 architecture.
- Understand the Cortex-M4 programmer's model.
- Learn the boot sequence and initialization process.
- Analyze compiler optimizations and techniques for writing efficient code.
- Interface C and assembly language.
- Manage interrupt handling.
- Develop serial communication drivers.
- Configure and use DMA transfers.
- Implement ADC functionalities.
Course Outline
- Day 1: Toolchain, Build Process & Debugging<
- Understanding the Toolchain<
- Cross-compilation principles<
- Role of compiler, assembler, and linker<
- C source program structure<
- Preprocessor directives: #define, #include<
- Writing macros and header files safely<
- Object file sections & library inclusion<
- Startup files and linker scripts<
- GCC compiler options<
- Running code from RAM<
- Writing Makefiles<
- Exercises:<
- Analyze build steps of a simple program.<
- Work with conditional compilation.<
- Configure the linker to allocate code and data.<
- Lab Environment Setup<
- Project creation from scratch<
- Debugging setup (debug probe, communication with target MCU)<
- Debugging windows (C/Disassembly, memory, stack, variables, registers)<
- Breakpoints and step-through execution<
- Day 2: Core C Concepts & Embedded Data Handling<
- Types and Operators<
- Variable storage classes (static, automatic, register, extern)<
- Scalar types (char, int, float, double)<
- Type conversion, casting, volatile keyword<
- Exercises: Work with types and operators.<
- Control Structures<
- if/else, switch/case<
- Looping structures (while, do/while, for)<
- Exercises: Implement control structures.<
- Pointers and Arrays<
- Pointer declaration, initialization, and operations<
- Constants, volatile and restrict pointers<
- One-dimensional and multi-dimensional arrays<
- Exercises: Work with pointers and arrays.<
- Structures and Unions<
- Structs, unions, bit fields, peripheral register modeling<
- Memory alignment, endianness<
- Exercises: Model STM32F4 peripheral registers.<
- Functions<
- Function prototypes, function pointers<
- Stack operations and recursion<
- Function inlining and pipeline optimizations<
- Exercises: Analyze stack usage and function calls.<
- Standard Library Overview<
- stdio library (printf, scanf, memcpy)<
- File access functions<
- Day 3: Embedded-Specific Programming Techniques<
- Data Structures<
- Implementing FIFOs, linked lists<
- Exercises: Work with linked lists.<
- Memory Management<
- Dynamic allocation (malloc, free), stack vs heap<
- Memory management algorithms (Buddy System, Best-fit/First-fit, Pool management)<
- Exercises: Implement dynamic memory allocation.<
- Embedded Context Considerations<
- Peripheral programming<
- Memory access and caching<
- Interrupt-driven programming<
- Exercises: Timer interrupt handling.<
- Cortex-M4 Architecture Overview<
- Harvard architecture, register model, execution modes<
- System control block, SysTick timer, NVIC interrupt handling<
- Exercises: Analyze the boot sequence.<
- Day 4: Advanced Topics & STM32F4-Specific Features<
- Compiler Optimizations<
- Function inlining, memory alignment, struct packing<
- Exercises: Mix C and Assembly, analyze function inlining.<
- STM32F4 MCU Overview<
- ARM Cortex-M4-based architecture<
- Bus matrix, memory mapping, DMA, UART, ADC<
- Flash programming, clocking, power management<
- Exercises:<
- Implement DMA-based data transfers.<
- Redirect printf output via UART.<
- Display ADC values on an LCD.




