As I mentioned last week, I am working on simulating a real UART device. Do you know what UART device is? Well, let me start by explaining a little bit about it.
UART stands for Universal Asynchronous Receiver/Transmitter. A UART is a microchip with programming that controls a computer’s interface to its attached serial devices. It allows the computer to talk to and exchange data with modems, serial ports and other serial devices. UARTs are commonly included in microcontrollers and are designed to be used for several applications. UARTs are used for devices including GPS units, modems, wireless communication and Bluetooth modules, amongst many other applications. However, these devices may use parallel communication while UART is an integrated circuit used for serial communications that contain a receiver and a transmitter.
Simply, the difference between parallel and series communication is that parallel connections have multiple wires running parallel to each other (hence the name) and can transmit data on all the wires simultaneously. Serial, on the other hand, uses a single wire to transfer the data bits one at a time.
Thus, transmitter and receiver translate data from parallel to serial and from serial to parallel, respectively. So, to make it easy, UART allows the board to communicate with other devices.
However, we do not need to have all the functions that a real UART can do in our UART simulator because many of them require a real hardware and not necessary as our UART runs on software. So, there is no need to make things more complicated for nothing. So, I will just stick to the UART simulator that I am building and explain how it works.
UART devices maintain a flag showing busy status. This busy flag is checked every time before transmitting or receiving data. That means a UART device has to be ready before transmitting or receiving data. If the flag value is 1, that means UART is busy, if it 0, it means UART is not busy. Also, in my UART Demo, I maintain a ready flag that indicates whether the buffer has information stored or not.
To make UART Demo work, I followed this procedure:
- Check the busy flag before transmitting or receiving information.
- When receiving, store data into the buffer of UART, and set the ready flag to 1. A buffer is a region of a memory storage used to temporarily store data while it is being moved from one place to another.
- Many inputs can be stored in the buffer.
- When transmitting, data that were stored in the buffer will be loaded one by one. Data that came first will be transmitted first.
- If the buffer is empty, the ready flag will be set to 0.
Finally, I still need to improve the structure of my code as Dr Shawn asked. He asked me to make my code simpler to read and to be edited later on. Finally, I have to make documentation to explain my work in details to make it easier for future interns to work on the project. By that, I finish my last task for my internship. Next week, I will recap my work and list out the things I have learnt during my internship. Stay tuned!