Microcontroller circuits

26,682

Circuit Image

Connect the serial cable to the serial port. If using a USB to TTL, RS232, or serial converter, plug it into the USB port. Next, short the Tx pin to the Rx pin or the TxD pin to the RxD pin using a jumper wire on the other side. Open a serial port terminal software, such as PuTTY, and establish a connection using the COM port. Once the connection is established, transmit any data. If the same response is received on the terminal software that was transmitted, the serial communication is functioning correctly. If the same response is not received, the serial communication link is faulty. If using a desktop PC's serial port, check the serial cable's connectivity using a multimeter. If the serial cable is fine, check the serial port on the CPU (DB9) by shorting the Tx and Rx pins again. This issue often arises with USB to serial/TTL/RS232 converters, as operating systems assign higher COM ports to these devices, while Flash Magic supports COM ports up to 32. Therefore, it is necessary to manually change the automatically assigned COM port to a value within 32. After changing the COM port, uninstall Flash Magic from the machine, restart it, and reinstall the software to try loading the hex file again. Baud rate refers to the number of bits transmitted per second, which indicates the speed of communication. The baud rate calculation includes start, stop, and parity bits, while the data rate only considers the number of data bits. Consequently, in UART communication, the data rate is always lower than the baud rate. The configuration must be identical at both ends for proper communication to occur. Under normal conditions, when no communication is taking place, the Tx pin is at a high level. When the start bit is received, it lowers the logic level, indicating to the other device that communication is beginning. After the start bit, the UART circuit receives the data bits. The decision threshold time occurs in the middle of the bit. When the UART module receives this frame, it removes the start and stop bits, calculates the parity if present, and performs the necessary actions, such as setting flags in registers or generating interrupts, to notify that data has been received. UART supports fixed speeds, with 9600 bps and 19200 bps being commonly used in embedded applications. The need for a Real-Time Operating System (RTOS) in embedded applications arises when a controller must manage multiple peripherals and input-output devices. When an embedded project contains numerous applications on a single hardware platform, an RTOS is more convenient than bare-metal programming. Designers often prefer an RTOS when a single hardware resource needs to be shared among many applications. An RTOS enhances code maintenance and debugging significantly. A modular development approach can be effectively managed using an RTOS. The choice between bare-metal and RTOS depends entirely on the system's complexity. In bare-metal applications, direct hardware access is possible, while in an RTOS, applications cannot access hardware resources directly. Instead, applications request access to hardware from the OS (the kernel part of the OS), and access is granted only if permitted by the kernel.

In the context of serial communication, the connection process involves establishing a reliable link between devices using UART (Universal Asynchronous Receiver-Transmitter) technology. The UART protocol is essential for enabling asynchronous serial communication, which is widely used in embedded systems due to its simplicity and effectiveness. The Tx (transmit) and Rx (receive) pins are crucial to this communication, where data is sent from one device to another through voltage level changes that represent binary data.

When configuring the serial connection, it is vital to ensure that both devices share the same settings, including baud rate, data bits, stop bits, and parity. This configuration guarantees that the devices can interpret the transmitted signals correctly. The baud rate, often set at common values such as 9600 bps or 19200 bps, determines the speed of data transfer.

In addition to the hardware connections, the software aspect plays a significant role in establishing communication. Terminal software, such as PuTTY, facilitates the user interface for sending and receiving data. Properly setting the COM port is critical, especially when dealing with USB to serial converters that may automatically assign higher COM port numbers.

The implementation of an RTOS in embedded systems enhances the ability to manage multiple tasks and peripherals effectively. An RTOS provides a framework for multitasking, allowing developers to create applications that can handle various input and output operations concurrently. This is particularly beneficial in complex systems where timely response to external events is crucial.

In summary, the combination of proper hardware connections, correct software configurations, and the potential use of an RTOS contributes to the successful implementation of serial communication in embedded applications. This approach not only ensures reliable data transfer but also facilitates the development of sophisticated systems capable of handling multiple tasks efficiently.Connect serial cable with serial port and if you are using USB to TTL or RS232 or serial converter then plug it to the USB port. Now after this short pin Tx with Rx or pin TxD with RxD using any wire like jumper wire on other side.

Now open serial port terminal software like putty or whichever you are using and make connection using COM port. After connection is established transmit any thing. If you receive same response on terminal software which you have transmitted then serial communication is working perfectly fine. But if you not receive same response which you have transmitted then serial communication link is faulty.

In this case if you ate using serial port of desktop PC then check your serial cable (connectivity of each pin using multimeter). If your serial cable is fine then next check your serial port on CPU (DB9) as did earlier by shorting Tx and Rx.

This problem arises mostly with USB to serial/TTL/RS232 converter. Operating systems allocates higher COM port to this devices and flash magic supports COM port upto 32. So it became mandatory to change automatically assigned COM port manually and limit it within 32. In this condition after changing your COM port uninstall flash magic from your machine then restart your machine and again install it back and try to load hex file.

Baud rate defines number of bits per second which simply means speed of communication. Noe baud rate calculation includes start, stop and parity bits as well. While in data rate only number of data bits are considered. Hence in UART data rate is always lower than baud rate. Above mentioned configuration must be same at both the end otherwise proper communicate is not possible. In normal condition that is when no communication, tx pin is at high level. When start bit comes it lower down the logic level which is indication to other device that start of communication or device connected with it is sending something.

After end of start bit UART circuit will receive for data bits to some. Decision threshold time is at mid of the bit. When UART module or circuitry receive this frame it removes start and stop bits and if parity bit is available it calculate parity then take necessary decision and finally it generates some notification stuff like setting up flag in registers or generates interrupts or something similar to that to notify it has received data. UART supports some fixed rate of speed but 9600 bps and 19200 bps commonly used in embedded applications.

Now coming back to need and use of RTOS in embedded application, RTOS is require when controller supposed to handle lots of peripherals and input-output devices. In other case when an embedded project contains more number of applications on single hardware RTOS is more convenient compared to bare-metal.

To be more specific most designer preferred RTOS when single hardware resources required to be shared by many number of applications. RTOS increase ease of maintenance and debug of code upto great extent. Modular development approach can be handled very effectively using RTOS. Selection of either bare metal or RTOS is completely depend on complexity of system. In bare metal application can directly access hardware while in RTOS application can not access hardware resources directly.

Application request OS (kernel part of OS) for required hardware access and if kernel permits then only it can use that resources. i will upload more article regarding RTOS here. Feel free to share, comment and give your valuable feedback. Suppose you are outsi 🔗 External reference