Back Channel
STM32 printf over ITM Exercise
Task
This board's only serial port is wired to its cellular modem, so a debug line sent there would garble the link. Your debugger can read text from the chip another way, on ITM stimulus port 0 over the trace pin.
Print the board's boot count once on ITM port 0, with printf, like this: boots:7 read_boots() returns the count. printf hands every character it makes to a function named _write, and you write that function. The registers and bit fields are on the Datasheet tab, under CoreDebug and ITM.
Circuit
Pass condition
ITM port 0 shows the line once, with this board's count, and USART1 sends nothing. Trace is set up the way a real chip needs it. Each test stores its own count.
Notes
Your program must work whether or not a debugger set trace up before it runs. Without one, the ITM starts switched off and locked. printf is never called from an interrupt handler. A handler records an event, and main prints it.