Course Code: embsysprogcbesp
Duration: 14 hours
Prerequisites:

Requirements – attendees’ background:
• basic knowledge of C programming language,
• knowledge of computer architecture & microcontroller basics.


Hardware environment – attendees – optional; if hands-on is required:
• PC running Windows 11/10, Internet connection
• STM32 microcontroller-based development board from Nucleo of Discovery family, USB 
cable with a proper plug for connecting the board to the PC


Software used for workshop examples, installed on attendees’ PCs:
• embedded: STM32CubeIDE – to be downloaded from st.com, microcontroller series 
package for STM32CubeIDE, installed from CubeIDE: Help-Manage embedded software 
packages-<select the package for the family used>
• for communication examples - optional: Serial terminal emulator TeraTerm 4.105 or newer, 
or similar (not RealTerm, not Bray Terminal; should be capable of tolerating USB 
disconnection) – only basic terminal functionality required.

Course Outline:

Outline – modules

Selected topics from computer architecture (2..3 hours)

Selected topics from computer architecture – computer operation, data in computer’s memory, 
execution of a high-level language program; memory sections. Role of stack. Data types; data in 
memory – alignment. Exceptions and their handling at hardware and software level. Procedure 
reentrancy. Semiconductor memory technologies. Program in hosted and freestanding environment.

Modern C language features related to embedded programming (3..4 
hours)

C language origins and standard development history – K&R, ISO C90, C99, C11, C18, C23. C as 
“high-level assembly” language.


Basic C language concepts – old and new simple data types. Declarations and definitions, source 
and header files. Type size and alignment. 


Enumerations. Aggregate types: vectors/arrays, structures, unions. Size and alignment of aggregate 
types, sizeof, alignof and offsetof operators. Portability of structures and unions. Compound literals.


Data declarations and definitions. Functions and their prototypes. External vs. local declarations. 
Data and function attributes: const, volatile, restrict. Storage classes.


Using printf and scanf family functions with explicit-size types.


Coding style for writing error-immune programs. Reducing the ranges and scopes. Object naming 
conventions. Common errors in C programs. Importance of static and const specifiers.

ARM M-line architecture overview (1 hour)

ARM Cortex-M processors - programming model, exception handling; multilevel interrupt system.

Embedded systems programming (approx. 7 hours)

Microcontroller as C language freestanding environment. Memory sections in microcontroller’s 
memory. Microcontroller resources’ visibility in C language.


Approaches to uC firmware design: event loop, event loop with interrupts, fully event-driven 
without polling loop, RTOS-based. Software state machines.


Exceptions and their handling in C. Firmware startup


Reducing the memory usage. Volatile specifier. Linking and linker scripts. Weak definitions of 
objects.


Register-level vs. library-based peripheral module programming – pros and cons.


GPIO and simple timers. Using timer interrupt in simple applications. GPIO initialization. 
Controlling the GPIO outputs. Using mechanical switches – no-nonsense debouncing methods.


Program debugging – single-stepping, breakpoints, examining data and peripheral modules.


Communication interfaces – general info. UART communication. Handling the UART using 
polling, interrupts and DMA. Using C standard input/output in a microcontroller.


Decomposition of firmware functions into thread code and interrupts routines – simple and 
advanced scenario. Event-driven programming for microcontrollers.


Polling-free, fully asynchronous software concepts. Useful techniques for microcontroller software 
design.