Project setup, serial output & a fixed-rate loop
Create the project, send text to the computer and see it in the serial plotter, then run the main loop at a fixed rate. First on STM32, then on ESP32 with the Arduino IDE.
Introduction: what we build in this course
IntrofreeNo code in this lesson. Watch the video, then start with lesson 1.2.
1.2STM32: create the project and send text over the UART
STM32freeWe start in STM32CubeMX with the Board Selector, turn on USART2, generate the code and open the project in STM32CubeIDE. Then printf goes to the UART, and we read the messages in the serial plotter.
1.3STM32: a fixed-rate loop with a timer interrupt
STM32freeTIM4 counts at 1 MHz and fires an update interrupt (a signal each time it reaches its period) every 20 ms (50 Hz). The main loop does its work once per tick.
1.4ESP32 (Arduino IDE): send text over Serial
ESP32freeThe same result on the ESP32, programmed in the Arduino IDE. Our board: the Arduino Nano ESP32 (ESP32-S3). Another ESP32 board works too: only the board name changes.
1.5ESP32 (Arduino IDE): a fixed-rate loop with micros()
ESP32freeNo timer interrupt: the loop checks the time with micros() and does its work every 1/SAMPLE_RATE_HZ seconds.