
Week 4: Embedded Programming
Table of Contents
This week we got introduced to embedded programming. Our tasks were to compare different development workflows for available embedded architectures, read the datasheet of one preferred micro controller unit (MCU), and to briefly demonstrate basic programming skills.
This Week’s Tasks
- Group assignment:
- Demonstrate and compare the toolchains and development workflows for available embedded architectures
- Document your work to the group work page and reflect on your individual page what you learned
- Individual assignment:
- Browse through the datasheet for your microcontroller
- Write a program for a microcontroller, and simulate its operation, to interact (with local input &/or output devices) and communicate (with remote wired or wireless connection)
Introduction to Embedded Programming
This week’s lecture covered aspects of embedded programming. It discussed selecting the appropriate MCU family, such as AVR or ARM, based on application needs. Different programming languages were explored, including C/C++, Rust, and (Micro)Python, each with its own advantages and trade-offs for embedded systems. The session also touched on development tools, debugging methods, and operating systems, highlighting the use of simulators like Wokwi and Tinkercircuit for testing and learning.
- group assignment
- https://fabacademy.org/2025/labs/ilmenau/assignments/week04/
- gute dokus:
overview
-
vergleichen
- mit ram, pins, on-board memory
- prozessorarchitektur etc
- prozessorfamilie
- toolchains & development workflows
- was brauche ich um das zu programmieren?
- früher alles mit: SPI protokoll. die programmerproduktfamilie heißt avrISP
- da hast du dann
- einen programmer (usb interface + pins + μC)
- das verbindest du dann mit den 6 pins an das board wo der chip drauf ist
- prtokoll wie programmer und μC miteinander reden heißt SPI
- es gibt aber andere protokolle dafür
- ???
- was sind gängige protokolle?
- ISP: in system programmierung. ICSP: in circuit serial programming (name englisch/deutsch)
- da hast du dann
- bei neuen μCs die kann man nicht mehr mit SPI kommunizieren.
- SPDI: 1-pin-programmierung (eigentlich 3 pins aber egal)
- ich bin etwas verwirrt von der ganzen terminologie. wichtig: es gibt 3 standards:
- spi
- spdi
- jtag (was ist das?)
- updi
- which programming protocol can be used for which processors?
-
μC kann analoge und digitale pins haben
-
fast alle pins können als digital verwendet werden
-
für analoge pins die haben einen adc drin. die können das z.B. integriert sein
-
alle pins können inputs und outputs sein (input).
-
die neuen tinys haben analogoutput aber das ist nicht die regel (wichtig dafür ist: DAC)
-
hersteller
- PIC, ATMEL und STM sind die großen chiphersteller
- neil hat sich eher für die atmel schiene entschieden
- pic hat nur funktioniert mit proprietärer software. genauso stm. ändert sich jetzt
- alles was wir haben ist von atmel außer von die samd and die esp32
what is platformio? https://docs.platformio.org/en/latest/what-is-platformio.html
what is an mcu?
group of microcontroller units (MCUs) that share a common architecture, design, and often the same core features
- ARM Cortex-M is a popular MCU family, where multiple manufacturers like STMicroelectronics, NXP, and Microchip produce MCUs that are based on the ARM Cortex-M core.
- AVR is another MCU family, famously used in the Arduino platform.
- PIC is a family of MCUs from Microchip Technology, with a range of devices from small 8-bit controllers to more powerful 16-bit and 32-bit versions.
Within each MCU family, you’ll typically see models that differ by features like:
- Flash memory size
- RAM size
- Clock speed
- Number of GPIO pins
- Peripheral support (e.g., UART, SPI, I2C, timers, etc.)
difference between microcontroller and processor
available controllers, when to use what
-
when to use what
- small size, low cost, low pin count, simple task: avr
- fast, parallel processing: rp2040
- radios: esp32
- embedded usp: samd
-
fpgas:
- more power-hungry
- vhdl or verilog, less intuitive to c
- larger in terms of physical size
- limited peripherals (adcs, uarts, pwm, etc)
- overkill for simple tasks. good for parallel processing though!
-
vergleichen: produktfamilien:
- rp2040 ist eine produktfamilie
- esp32xx
- samd21 etc.
- samd11 etc.
- attinyxx
- avr128
Programming
-
which dev workflow is there?
- arduino ide
- platformio
- command line over avrdude
- one of thousand other programming environment. however they are based on avrdude or a commercial variant of it.
- machen alle das gleiche
- avrdude macht hexfile aus deinem code
- und lädt das dann auf deinen μC
- den programmer brauche ich nur für die übersetzung von usb zu programmer protocol
-
es gibt 2 varianten:
- man beschreibt die μCs extern das wäre dann das mit dem programmer
- ein μC hat einen bootloader der irgendwie es möglich macht ohne programmer code auf den μC zu packen. ich weiß aber nicht, inwieweit das funktioniert.
-
which workflows / protocols can be used for what controller? (multiple possible?)
-
alle programmierer die wir zur verfügung haben hinpacken (ferdi)
- the act of programming a microcontroller while it is already mounted on the board
- Contrary to Pre-Programming. You program the contro
CMSIS-DAP Devices are all devices that can write programs into a microcontroller’s memory using JTAG or SWD. ler before soldering it somewhere.
Serial Peripheral Interface (SPI)
- A standard synchronous serial communication interface used for short-distance communication between a main device and one or more peripheral devices.
- synchronous (needs clock signal), serial communication
- multiple secondary devices are possible
- full-duplex
- pins:
- MOSI (main out secondary in)
- MISO (main in secondary out)
- SCK (clock)
- SS (secondary select): select which secondary device to communicate with
Serial Peripheral Data Interface (SPDI)
- do not find any source for it
Joint Test Action Group (JTAG)
- eletronics manufacturers committee
- they developed a protocol with the same name
- mostly used for programming ARM cores
- pins
- TMS: mode select
- TCLK: clock
- TDO: data out
- TDI: data in
- nRESET: reset (optional)
- two-pin variant of the JTAG protocol
- most common on newer ARM chips
- pins:
- swdio: in/out
- swclk: clock
Unified Program and Debug Interface (UPDI)

- proprietary
- single-wire,
- bi-directional, half-duplex
- asynchronous
- can use off-the shelf UART adapters
- used to program AVR microcontrollers released since 2016, ATTINY412, ATTINY164.
- more detailed blog article
- debugging is hidden behind a proprietary interface, but even though you can snoop on the protocol with just a serial adapter and even though the large scale structure of the protocol is known too
- even more detailed article
- i did not find out what part of the protocol actually is proprietary and what not.
Components
what elese do we have?
- kondensatoren
- widerstnde
- diode mosfets
- LEDs
- infrarotleds
- sehr helle weiße led
- neopixel
- voltage regulatoren
- switches
- taster
- terminal blocks, connection stuff
- flachbandkabelsockets
- other connectors…
- mit ohne zugentlastung
- handle tool?
- usb c breakout board
- batteriehalter
- pinzetten
Choosing a Controller
- for further development
decide for a microcontroller
-
choose for one.
-
maybe choose so it fits to your final project
-
something with audio
-
so an analog out would be nice
-
something fast
-
check for dma. feature so that hardware subsystems dcanddirectly access memory. cpu can do something else
-
check how other audio assignments did it
-
check for output week
-
https://hackaday.com/2025/02/14/a-guide-to-making-the-right-microcontroller-choice/
- at least 16bit. want good sound quality
- 8bit is also aesthetic, but i like crisp sounds
- clock frequency? floating oint vs fixed point?
Previous Projects
other projects doing synthesis:
-
- used Teensy for synthesis
-
- used rp2040
-
- nimm das und pass das an.. https://github.com/maltman23/ArduTouch/tree/master/Arduino/libraries/ArduTouch
-
https://fab.cba.mit.edu/classes/863.22/Harvard/people/Selin/final.html
pieter did play with music http://fabacademy.org/2023/labs/waag/students/pieter-hijma/week-11/index.html https://fab.cba.mit.edu/classes/863.24/people/AntonisChristou/posts/week12/ http://archive.fabacademy.org/fabacademy2016/fablabkamplintfort/students/125/project_result.html http://fab.cba.mit.edu/classes/863.08/people/Tomas/review/index.html https://fab.cba.mit.edu/classes/863.22/Harvard/people/Selin/final.html
https://fabacademy.org/2024/labs/waag/students/leo-kuipers/final-project/07_electronics/ https://fabacademy.org/2024/labs/waag/students/edwin-dertien/project/presentation/
- 8bit mixtape
Asking Professionals
fragen an ferdis kumpel: michael kraft (audiodevel)
- bastler: teensy
- kommerzielle synths: fpgas, asics
- was nimmt man jetzt, wenn man bastler ist aber das ganze möglichst "richtig" machen will
- siehe
Monophon:
Arm cortex 7 oder 5
Modular:
Monophon cortex m 4 und stm
Herangehensweise ist eichtig.
Problem: wenn du nahe 0 kommst schaltet das auf 64 bits. Das will ich nicht. Arm cortex haben dsp intrjnsics. Nahe 0 wird gleich 0.
Eichtig: ganze entwicklung muss extern stattfinden.
Ktieg software erstmal auf computer zum laufen. Möglichst auf nem 32 bit computer. Setz vm auf mit 32 bit
Dann entwicklungsumgebung entspricht arm cortex.
Bei Mcus hast du möglichkeit zu optimieten. Kann man nicht debuggen. Du musst auf n system entwickeln wo ich debugge und dann lass ich das laufen
Klangsynthesemögliche
Teensy sagt ihm nichts
Reine dsps lohnen sich nicht mehr. Arm kann das auch. C intrinsics. Prozessoren haben assembler befehle für dsps. Um da ranzukommen definirst du ein c intrinsic. In c wie funrion. Ruft in wirklichkeit n bestimmtes code in aseembler auf das das macht was du beauchst.
Bsp saturation. Normal: if else. Wirklichtkeit: sat intrinsic.
Arm selbst verkauft keine chips. Wichtig wo du den kaufst
Kleinste arm cortex m0
M2 m3 etc
Ab cortex m4 fpu. Muss für audio. Immer mit fp in plus minus 1 berechnen. Voteil: multiplikation ist in eimem cycle gemacht. Division ist 80 cyc. Mit floating points in m1 1, kann man alles mit mult machen
11m
Du brauchst nen floating point prozessor.
Hersteller: lass finger von atmel arm. Nxp auch.
Stm sehr gute entwicklungsumgebung. Mausr.com elektronikvertrieb. Guck unter stm32 für dwv boards. Haben riesenliste an dmv boards . nucleo boards. Hardware codecs. Evaluation boards. Wichtig. Brauch ich wenn ich in hardware reingehen will.
Rp2040 ist ein eval board. Stm hat komplettes system dafür. Site ist st.com.
Mausr kannst du dinger kaufen.
Ansonsten alles andere was fpu etc hat. Auf github gibts viele projekte für audio auf raspi.
Mcu ist ne ecke billiger
Kommerziell nimmt man
Hängt davon ab was du machen willst. In entwicklungsprozess v elektrobik. Erstes ist sys engineering. Was rechenleistung was hardwaremäßig etc. Bürokratischer aufwande dwn ich brauch. Wird oft geschlampt. Das ist wichtig. Musst swhen wo dinge ihre limits haben wo nicht.
Wenn du rausfinden willst was du entwickeln willst nimm dafür ein größeres system. Dann weißt du was du brauchst. Wenn du das direkt auf hardware machst schwierig.
Speziell jm audio willst du viel experimemtieren. Tu das auf nem computer.
-> esp32 dinger haben fpu und dsp:
- https://github.com/espressif/esp-dsp
Links
ferdi
:
5:39 PM
Und ein paar links für audio/DSP (von michael kraft)
Theory:
https://www.dspguide.com/pdfbook.htm - That's the heavy stuff!
https://sengpielaudio.com/ - gut zum Nachschauen von basics
http://www.musicdsp.com/ - loads of source code for audio algorithms!
Hardware:
https://www.mouser.de/c/embedded-solutions/engineering-tools/embedded-processor-development-kits/development-boards-kits-arm/?q=stm32f7 - ARM Cortex M7 evaluation boards (not audio specific, but quite powerful for an MCU)
https://www.mouser.de/ProductDetail/Espressif-Systems/ESP32-LyraT-Mini?qs=Cb2nCFKsA8pQPMrYjINZiw%3D%3D - Audio development board with ESP32
https://www.espressif.com/en/products/devkits - more low cost ESP32 kits, incl. audio specific
https://github.com/GuitarML/NeuralPi -…
Ich denke am einfachsten ist es mit dem ESP32 Lyra board anzufangen.
https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/dev-boards/get-started-esp32-lyrat-mini.html
possible audio
- there is fixpoint arithmetic
- there is floating point arithmetic
- i did not understand how to use it when
literature on ep in general
https://kleinembedded.com/stm32-without-cubeide-part-1-the-bare-necessities/
literature dsp, audio synthesis
Fixed-point math library for C
do i really need fpu? https://www.analog.com/en/resources/technical-articles/fixedpoint-vs-floatingpoint-dsp.html
-
fpu:
- much larger dynamic range
- higher precision due to less quantization error
- easier development -> lower production cost
-
con:
- processor cost
-
i did not know what exactly would it mean to differ between fix point and floating point
-
since i did not have that much experience, i went with choosing a processor with an fpu. i dont know what exactly would be easier for the development, but i will see. the only processor that has one is the esp32 s3.
checking faust
faust
- functional programming interface that lets you define your stuff
how to generate c code from it?
you can compile faust code without fpu
https://github.com/pschatzmann/arduino-audio-tools/wiki/Faust
good to go
only mcu with fpu: esp32s3 for now: use esp32s3, later (if time) reprogram everything for another microcontroller/do the next project with another microcontroller
- because i learn faust newly

import("stdfaust.lib");
ctFreq = 500;
q = 1;
gain = 1;
process = no.noise : fi.resonlp(ctFreq,q,gain);

- safe as faust.dsp
- compile to c
- using this article
- https://www.pschatzmann.ch/home/2022/04/22/using-faust-dsp-with-my-arduino-audio-tools/
- double checking with faust manual
- follow up: integrate that into microcont. save that for input week
Reading the Manual
terminology
- dram vs sram?
- dram: requires external memory refresh while. designed with capacitor and transistor -> higher density than sram which is implemented using flip flops.
- both ram types are volatile, data is lost when power is removed
- sram is faster (read, write)
- dram can be bigger (higher density)
datasheet
- we have seed esp32 s3
- manual says, there are different versions of that.
-
seed esp32s3 has
- no flash
- 8MB psram (good, following pschatzmann)
- strapping pins. pins used to pass specific parameters to the chip durin startup or reset.
- possible features: upgraded heat sink, antenna and camera
- battery: there is internal power management. if you use that, take qualified rechargeable 3.7V lithium battery
-
found resources:
- Hardware Design Guidelines for hardware integration
- Technical Reference Manual
- Datasheet
-
the datasheet is like an overview for everything else. in the following i will summarize that.
-
chapter 1: overview
- general information that can be read later when necessary
- functional block diagram as overview
- list of features for wifi, bluetooth, cpu etc.
- has fpu + l1 cache
- rom 384kb: read only memory
- sram: 512 kb: static random access memory
- volatile, data lost when power removed
- uses latching circuitry
- holds its data permanently in presence of power while in contraslt dram decays in seconds and must be periodically refreshed
- sram is faster than dram
- sram more expensive than dram
- sram is used for cache and registers
- peripherals
- gpio
- spi
- lcd
- dvp camera interface
- uart
- i2c
- i2s
- rmt
- pulse counter
- led pwm
- full-speed usb otg
- usb serial jtag
- two motor control pwm
- sd/mmc host controller with 2 slots
- general dma
- twai
- speaks JTAG for debugging
- on-chip debug via jtag
- timers
- cryptographic hardware acceleration
- analog
- two 12 bit adcs
- temperature sensors
- touch sensors
- does not have dac! for final project i would need to use pwm for audio output or an external dac (edwin dertien)
- nomenclature: we have an ESP32-S3 R8
- PSRAM, 8MB
- what is PSRAM?
- pseudostatic ram
- refresh and address-control circuitry, behaves similar to sram
- dynamic ram with built-in refrsh and address-control.
- combines ease of use of sram with high density of dram
- PSRAM is a type of memory that behaves like SRAM but is based on DRAM technology. It combines the simplicity of SRAM’s interface with the high density of DRAM, making it useful in applications where low-cost and high-capacity memory is needed, such as mobile devices and IoT applications.
-
chapter 2: pins
- pin multiplexing, controlled via software programmable registers. done in arduinoide by pinMode function
- pins have different functions. some have adc behin dthem so they can convert analog to digital signals
- some pins have rtc functions (real-time clock)
- some pins have analog functions ()
- further features are listed
- digital output: 1.1v
- has external clock input/output. might be useful for synchronizing multiple parts.
- pin mapping for different modes
-
chapter 3: functional description
- cpu and memory
- rtc and low-power management. can be configured to power up different power domains of the chip to achieve the best balance between chip performance, power consumption, and wakeup latency
- system components
- interrupts: level-triggered or edg-triggered; timer-triggered, software-trigered, etc.
- permission control
- sys registers to configure peripheral blowcks and core moduels (clock, power-management, memory, etc.)
- The Clock Glitch Detection module on ESP32-S3 detects glitches in external crystal XTAL_CLK signals
- digital peripherals
- IO MUX, GPIO Matrix
- spi
- interfaces forlcd interface, camera, uart controller
- i2c interface for inter-device communication
- i2s interface
- remote control peripheral for creceiving IR signals.
- pulse conut controller can be used to count pulse edges
- a controller for led pwm
- …
- motor control pwm controller
- sd host controller
- radio and wifi
- bluetooth le
- timers and watchdogs
- cryptography acceslerator, among others for sha, aes and rsa. it also can generate true random numbers
- pins can be configured to have specific function in a protocol.
- cpu and memory
-
chapter 4: electrical characteristics:
- absolute maximum ratings. Stresses above those may cause permanent damage to the device. However, just maximum ratings. Exposure to absolute-maximum-rated conditions for extended periods may affect device reliability
- recommended input voltage for all pins is typically 3.3V. For how much you can deviate from that, check the tables.
- adc characteristics
- current consumptions
- wifi radio characteristics
features to look into
- power management
Other MCUs
- rp2040: pios for lighting
- attiny for simple tasks
Setting Up
Arduino
- looking forward to do advanced audio stuff. however, for that i need more time
- now, just for assignment fulfillment






1// the setup function runs once when you press reset or power the board
2void setup() {
3 // initialize digital pin LED_BUILTIN as an output.
4 pinMode(2, OUTPUT);
5 Serial.begin(9600);
6}
7
8// the loop function runs over and over again forever
9void loop() {
10 int ms = millis();
11 int d = sin(ms / 100);
12 Serial.println(d);
13 digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level)
14 delay(d); // wait for a second
15 digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
16 delay(d); // wait for a second
17}
1// the setup function runs once when you press reset or power the board
2void setup() {
3 // initialize digital pin LED_BUILTIN as an output.
4 pinMode(2, OUTPUT);
5 Serial.begin(9600);
6}
7
8// the loop function runs over and over again forever
9void loop() {
10 float s = millis() / 100;
11 float sinarg = fmod(s, TWO_PI);
12 Serial.println(sinarg);
13 float d = 127*(sin(sinarg) + 1);
14 Serial.println(d);
15 digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level)
16 delay(d); // wait for a second
17 digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
18 delay(d); // wait for a second
19}
changed setup to connect led to pwm (analog) port.
was a bit too wonky.
1void setup() {
2 pinMode(A3, OUTPUT);
3 Serial.begin(9600);
4}
5
6void loop() {
7 float t = millis();
8 float sinarg = fmod(t/1000, TWO_PI);
9
10 float level = 100;//127*sin(sinarg) + ;
11 Serial.println(level);
12
13 analogWrite(A3, level);
14}
led seemed not to change luminance with varying pwm frequency
[[[work process detail in past tense]]]
ESP32-S3



1void setup() {
2 Serial.begin(115200);
3 pinMode(D2, OUTPUT);
4}
5
6void loop() {
7 Serial.println("on");
8 digitalWrite(D2, HIGH);
9 delay(1000);
10 Serial.println("off");
11 digitalWrite(D2, LOW);
12}

Reflections
What I Learned
This week for me was mostly about learning the background of embedded programming. How to put code on an MCU, what are the corresponding protocols? I also learned technical details about how to do DSP, in particular for audio on an MCU and what technical requirements persist for that.
What Went Wrong
Due to two exams I had this week, I was not able to get to run code on the ESP32, in particular I did not get to try out running DSP code generated from FAUST on it. Apart from that, the documentation was not finished until week 6. In the following weeks, I improved my time management in that respect.
What Went Well
The group assignment went very well. We worked together efficiently and shared tasks among each other in a reasonable way. Apart from that, Ferdi connected me with a friend him who has quite some experience with audio programming.
What I Would Do Differently
I would finish writing the documentation text as soon as possible, as I did in week 6.
Digitial Files
- Arduino sine blink
- Simple noise generation with FAUST
Use of Language Models
During writing this report, I used the following prompts asking ChatGPT 4o mini to …