Andrew NeilBest answer
Super User
January 10, 2025
Sure, you can use GPIO pins to "bit-bang" any protocol you like (subject to performance limits) - but that requires you to code every single rising edge, delay, falling edge, and sample in code.
That's very heavy on you writing the code, and on the processor having to run it.
Therefore microcontrollers have dedicated hardware blocks for doing common things like SPI, I2C, UART, etc
That relieves both you of having to write, and the processor of having to execute, all that tedious bit-twiddling - you can just pass data to the SPI unit, and it handles it all in hardware.
And hardware can give much higher performance than "manually" twiddling bits by software.
This is general across all microcontrollers - not specific to ST or STM32
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
