The final component that needs to be explored in this example is how data will be sent to UART2. These examples are meant to simulate external data being received by USART2. To achieve this without additional hardware, we wired together UART4 Tx and USART2 RX pins earlier in the chapter. The call to startUart4Traffic() is a TimerHandler prototype. A oneshot timer is started and set to fire 5 seconds after the application starts.
The function that does all of the heavy lifting is SetupUart4ExternalSim(). It sets up a continuous circular DMA transfer (which executes without CPU intervention) that transmits the string data from uart4 repeatedly. A full example using DMA will be covered later in this chapter – for now, it is sufficient to realize that data is being sent to USART2 without involvement from the CPU.