STM32 general purpose timer as a trigger for multiple time dependant events

Imagine, you're building a TDMA application with an STM32 controller and you're solving the problem of precise timing for multiple events. TDMA stands for Time Division Multiple Access. It is a channel access method that allows multiple users to share a common data channel (e.g. the same frequency) by dividing the signal into different time slots. In the followong playground TDMA system with three time slots, the master transmits in slot #0 and it receives from three other users in slots #1, #2. The transmit function is called at time T0=0, and the receive functions are called at times T1, and T2, respectively. The later times are all based on the master clock T0, but they may be slightly adjusted to compensate for the delays of the remote devices. A neat way to solve this timing issue is to use a timer (e.g., TIM2) with multiple channels to generate all the required times. The timer overflow event can be used as the master clock, which triggers the transmit function. Two ou...