USART

The microcontroller has a peripheral called USART, which stands for UniversalSynchronous/Asynchronous Receiver/Transmitter. This peripheral can be configured to work withseveral communication protocols like the serial communication protocol.

Throughout this chapter, we’ll use serial communication to exchange information between themicrocontroller and your laptop. But before we do that we have to wire up everything.

I mentioned before that this protocol involves two data lines: TX and RX. TX stands for transmitterand RX stands for receiver. Transmitter and receiver are relative terms though; which line is thetransmitter and which line is the receiver depends from which side of the communication you arelooking at the lines.

We’ll be using the pin PA9 as the microcontroller’s TX line and PA10 as its RX line. In otherwords, the pin PA9 outputs data onto its wire whereas the pin PA10 listens for data on itswire.

We could have used a different pair of pins as the TX and RX pins. There’s a table in page 44 of theData Sheet that list all the other possible pins we could have used.

The serial module also has TX and RX pins. We’ll have to cross these pins: that is connect themicrocontroller’s TX pin to the serial module’s RX pin and the micro’s RX pin to the serial module’sTX pin. The wiring diagram below shows all the necessary connections.

USART - 图1

These are the recommended steps to connect the microcontroller and the serial module:

  • Close OpenOCD and itmdump
  • Disconnect the USB cables from the F3 and the serial module.
  • Connect one of F3 GND pins to the GND pin of the serial module using a female to male (F/M) wire.Preferably, a black one.
  • Connect the PA9 pin on the back of the F3 to the RXI pin of the serial module using a F/M wire.
  • Connect the PA10 pin on the back of the F3 to the TXO pin of the serial module using a F/M wire.
  • Now connect the USB cable to the F3.
  • Finally connect the USB cable to the Serial module.
  • Re-launch OpenOCD and itmdump

Everything’s wired up! Let’s proceed to send data back and forth.