Communication Protocol\’s in Embedded:
Table of Contents
Communication Protocols in Embedded System
Serial communication
In serial communication, we have only one line for transmitting and receiving data which is why it is half-duplex. It is best for high frequencies as it uses only a single bus or channel for communication, but it can be a bit slower than parallel as it sends only a single bit per clock pulse also because of the single wire here we have fewer chances of cross-talks. It can detect the error as well.
When transferring a bit quick change in voltage are required like for 5v OS, 0 bit communicated as a short pulse is 0v, and 1 bit communicated by a short pulse of 5v. In serial communication, the first bit is the most significant bit and the last one is the least significant bit.
Parallel Communication
In parallel communication, we have a number of lines or buses equal to the number of bits we are transferring. We call it full duplex as the line for transmitting and receiving bits is different. It is faster for small frequencies as all bits are sent at once but as we have to use multiple wires it is costlier also here, we have lots of chances of cross-talks.
As in serial, here also we have the first bit is the most significant bit and the last one is the least significant bit.
How do they convert?
The protocols we have read above communicate in serial form, but they get the data from their peripheral device in parallel form. How do bits get converted into serial form to parallel form? Suppose we have 4 bits, to convert them from parallel to serial we need a Parallel to Serial converter, In the same way, if we want to convert parallel from series, we need a serial to parallel converter. Here comes the D Flip-Flop which is specially designed for such conversions.
What is Flip-Flop?
A basic memory element or basic digital memory circuit is known as Flip-Flop. It is some medium in which one bit of information (1 or 0) can be stored or retained until it\’s necessary.
- As one flip-flop can store one bit of information. To store multiple bits, we need multiple flip-flops.
- The group of flip-flops, which are used to store the binary data is known as register.
Flip flop circuits are classified into four types based on their use:
- D-Flip Flop
- T- Flip Flop
- SR- Flip Flop
- JK- Flip Flop.
Here for conversion between Serial and parallel bits of data D-Flip Flop is used.
Now, what is D Flip-Flop?
D flip-flop is also known as Data or Delay Flip-Flop. It has a single D input and a clock input C which is why we call it a D flip-flop. Or for the word delay, it describes what happens to the data at input 0. The data at D input is delayed by one clock pulse before it gets to the output Q.
There are two different ways of conversions:
- Parallel to Serial conversion.
- First, we need Flip-Flops equivalent to the number of bits. Then we will put the multiplexer in between the Flip-Flop.
Multiplexer- It is a combinational circuit that takes input from one of many input lines(parallel) and directs it to a single output line(serial).
It has two inputs:
1) From the previous Flip-Flop
2) From Parallel bit data.
Now we will load the data which will be transferred one by one.Here msb will be transferred first.
- Serial to Parallel conversion.
- First, we need Flip-Flops equivalent to the number of bits. This time we won\’t put the multiplexer in between the Flip-Flop.
- We need to store all the bits at first for this we will pull the clock signal low. Once all bits are loaded, we will pull the clock signal high, and it will shift the LSB to the input of Flip-Flop 1 and output of Flip-Flop 0. Same way all bits gets transferred.
- Now all the bits are stored in these Flip-Flop and as shown above all the Flip-Flop will transfer the bits at once the way it happens in parallel..
Overview about Serial Communication Protocols in MCU
UART Protocol
What is UART Protocol?
UART stands for Universal Asynchronous Receiver/Transmitter. As we can understand by the name it says it receives and transmits asynchronously. Asynchronously means it doesn\’t use clock pulse to synchronize the transmitter and the receiver.
In UART, the transmitter takes the signals in parallel from a controlling device[ex-CPU] then it sends the bits to a receiver in serial then the receiver converts those bits in parallel again. UART follows one master one slave approach as it uses only 2 wires for communication. It has one transmitter and one receiver.
How does it work?
As I, ve mentioned above it transmits asynchronously hence it uses a start and stops a bit, in it contains main data and a parity bit. The parity bit is only needed if the device needs to check the error.
When the device wants to start the communication, it pulls the transmitting line low which means it sends a 0 bit and receiving device understands that the transmitter wants to send the data. When the transmission line goes lows it stays low for one clock pulse and then it starts sending the data of 8 bits then the 9th one is a parity bit, the last one is stopping bit it stays high for the one clock pulse until the transmitter sends a low bit to start another frame.
To get, in detail understanding on UART Protocol, refer to this blog.

SPI Protocol
What SPI Protocol is?
SPI stands for Serial Peripheral Interface. Just like UART it also uses Serial Communication for transmitting and receiving data but instead of asynchronous it uses synchronous communication protocol for transmission.
Synchronous means the transmitter and the receiver must have the same clock signal. It uses a Full duplex communication protocol which means it can send and receive at the same time. SPI follows one Master multiple slave configuration.
This protocol has 4 parts
1. MOSI-Master Out Slave In
Here Master sends data to the slave and the slave receives the data. Master sends data to each device it is connected to via a single wire.
2. MISO-Master In slave out
Here Slave sends the data to the master and the master receives the Data. Master receives the data from each device it is connected to through a single wire.
3. CLK-Clock Signal
It is important for synchronizing the data when the master sends or receives it.
4. CS/SS-Chip select/slave select
We have different wires connected to the chips. Suppose we have 3 chips connected. Then the master would have three wires cs1,cs2,cs3 connected from chip1, chip2,chip3 individually.
To get in detail understanding on SPI Protocol, refer this blog.

I2C Protocol
I2C stands for the inter-integrated circuit. If you have read carefully about SPI and UART you will find I2C got the best features of these two.
It follows multi-master protocol as multiple masters through a single slave or to multiple slaves. It is a half-duplex communication protocol since it has only one line for transferring and receiving data. It is also called Two Wired Interface as it uses two wires for communication.
This protocol has 2 parts
- SDA: For sending bits
- SCL: For synchronizing the data.
How does it work?
In I2C as we have multiple slaves, every slave must have a different address before sending a bit master will address or call the receiver. If we have multiple masters then the master will check the clock signal. If it is high it will send the data or if it is low then it means another master is sending the data at the moment.
To get more in detail understanding of I2C protocol, refer to this blog.
Conclusion Para
- In the end, if you want to use two devices then UART works best and fastest.
- If you have multiple slaves and one master then I would suggest going for SPI
- And if you want to connect one slave with multiple masters then I2C is the fastest as it lowers the wirings as well.
Other blogs to explore
About Microcontrollers
About IoT

UART Peripheral in S32K144 MCU
LPUART Peripheral in S32K144 MCU || Briefing about LPUART Peripheral in S32K1xx MCU’s
Software Development Kit In Microcontrollers
Overview So hello guys, welcome to series of Microcontroller tutorials. As Microcontrollers are big thing happening across the globe, but to learn about microcontrollers becomes quite challenging as most of the content on web is theoretical based and quite unorganized. Or the content is only roaming around 2-3 microcontrollers (Arduino, ESP or PIC), even though there are number of Microcontrollers of different vendors. Also, framework of Arduino and Arduino IDE hides most of the things that are going inside the microcontrollers. Would recommend viewers to read these 3 blogs in order, so as to get understanding on how to get started with any Microcontroller and in what order. How to start with Microcontrollers? – gettobyte Hardware Development Kit In Mcrocontrollers – gettobyte Software Development Kit In Microcontrollers – gettobyte Here at Gettobyte, you will get content on microcontroller tutorials for different vendors in chronological way and covering the topics, in a much more interesting and story kind of way to make people understood easily. NXP Semiconductors – gettobyte Nordic SoC – gettobyte STM32 MCU’s – gettobyte Texas Instruments – gettobyte Silicon Labs – gettobyte AVR MCU – gettobyte ESP SoC – gettobyte Which will help you to learn important skills to build you Carrer on Semiconductor Industry and also help you in product development/DIY projects for different Industries, so as to make embedded devices with Industry standard Microcontroller. In return what Gettobyte platform seeks is that if you find these blogs insightful, then share it with people so make the reach more. And provide with constructive feedback and reviews in blogs comment section . If you guys want to start with microcontroller coding and looking for chronological order, then you have come to right place. In the last 2 blog: we get to know a lot about microcontrollers and how to start with them. And Hardware Development KIT in microcontrollers. One of the essential and important things to know before starting with microcontrollers is Software Development Kit. So, let’s start with it. In this blog we are going to start with another essential and important things to know before starting with microcontrollers that is Software Development Kit (SDK). Objective of this blog Objective of this blog, will be to understand: What is Software Development Kit in Embedded (SDK). Different components in Software Development Kit in Embedded. Why there is need of Software Development Kit in Embedded. What is Software Development Kit? Software Development Kit in embedded is collection of Software tools and applications, Software libraries, documentations to program the microcontrollers via host computer. Software Development Kit(SDK) majorly include: Software Stack for Microcontrollers Code Configuration Tools Software Debugging Tools Software drivers for debuggers and programmers. Integrated Development Environment (IDE) Software Stack for Microcontrollers Microcontrollers are not only hardware devices, but there is also very good amount of software used in microcontroller to run them, which are termed as software stack for microcontrollers. Software stack for microcontrollers can be divided into following components: Peripherals Drivers/Real Time Drivers: for using the peripherals of microcontrollers. This software controls the registers of microcontrollers to configure, enable, disable and use the different peripherals of microcontroller. Every MCU vendor design and develop these Drivers for their corresponding microcontroller. so that application developers can directly start with application development instead of creating these drivers on own. These drivers are kind of bare metal programming, as it is register level programming. which are written using C/CPP language using the concepts like Functions, loops, variables, static, user defined data types (typedef, Enums, structures), arrays and etc. For e.g. NXP semiconductors has S32K Standard software stack for its S32K1 Microcontrollers. Texas Instruments has Miscellaneous Stack: Peripheral Drivers is stack to drive the microcontroller peripherals, but with these peripheral drivers their is use of other embedded software technologies to build complex and real time applications like RTOSes(FreeRTOS, ChibiOS, Mbed and etc), IoT protocols Stacks( WiFi, BLE, Lora, LwIP, MbedTLS,and etc), Bootrom(openBLT), Sensor & Module drivers, crytography stack for providing security and safety in embedded applications, mathematics or signal processing algorithms stack for doing complex calculations. These all are also written using C/CPP language and it requires knowledge of programming along with hardware knowledge too. Peripheral Abstraction Layer/Hardware Abstraction Layer: This software stack is for code portablity and modularity in microcontrollers. Their are so many microcontrollers out their and for every MCU their is different peripheral driver. So if we change the microcontroller in our application, we need to rewrite the code of our application. This can be very cumbersome, there is need of some form of abstraction layer, through which our application end APIs remain same and just low-level driver files has to be changed if hardware is changed. This is done through the concept of C/CPP programming with use of programming concepts like, Classes, Structures, function pointers, templates, MACRO definition, linked lists and etc. In the large code bases like Autosaur and Ardupilot, Code portability is very essential, and use of Abstraction layers are heavy implemented through advance programming concepts like that of OOPS. For the starting we would just be needing peripheral drivers and abstraction layer stack of microcontrollers. These are provided by corresponding microcontroller vendors. // Examples of different peripheral drivers of MCU’s Code Configuration Tools As told in above sections there are many software stacks used in microcontrollers, so to design and develop the code using these software stack from scratch would be very cumbersome. As we need to include files for every stack and necessary configuration has to be done for building and compiling the code. So Code Configuration Tools are the software tools, which provide GUI based interface and environment to configure the software stack. We just need to select the hardware(microcontroller), what features we need and what all software components and peripheral to be enabled and then click on a button to generate the code. These tools then generate all the base software automatically from startup code to make files for the configured project. The features of CCT includes Graphical User Interface (GUI), tools for configuring peripherals, code generation and project building. In
course navigation
Primary Secondary Success Danger Warning Info Light Dark Link This page is Amazing

FlexTimer peripheral of NXP S32K1xx MCU( S32K144 MCU and ElecronicsV3 Board)
Learn how to use FlexTIMER peripheral of Automotive MCU S32K1xx using ElecronicsV3 Board (S32K144 MCU) by understanding FlexTIMER peripheral.

Debug and Trace: ARM CORESIGHT ARCHITECTURE
Table of Contents Other Processors to know about Overview In my Last Blog We talk about Trace and Debug Features in Firmware development. What role does they play and their importance in Developing Firmware for any project and Product can be of Great Importance. Now If you are an enthusiastic engineer just like me. You might be interested in how Debug and Trace things are working and implemented in our Embedded Controllers. Like Our CPU processors are running at higher frequency of more than 10 MHz (Just to tell Some even run at more then 100-200 MHz). That is, they can perform 1000000 instructions in just a single second!!!! That is fast and insane. As I have mentioned in Previous Blog about the Debugging Features, one can execute the instructions line by line. By that I mean that one can execute 1 instruction at a time. Just imagine how fast it executes 1 instruction and one can control those executions which are happening in ns,ms,us. Doesn’t this excite you; how does that happen???????? Or if We talk about Setting Breakpoint and then halting the processor, like it means when the CPU is executing 10000000 instructions per second. One can stop Our Machine that is running at the speed of MHZ at any Particular Instruction!!!! If talking About Trace Features, it tells about our code Performance and efficiency. So, generating data like How much time does the instructions take, time for their execution, space used by them and the effect of them in our Code and Performance. Does it not excite and make you think that how actually all these things are happening inside our MCU Core Processor. And remember guys all such things are happening at a time delay of ms, ns, us. That is fast and insane. So, telling You Answer for these Questions, As I have mentioned in My previous Blog also that Trace and Debug is just like a Peripheral in our Core Processors. And they have their Own Circuitry, Components, Communication Protocol, Communication Pins, Communication Busses and Own Programmable Registers for configuring Which Debug and tracer features to use and setting them up. In the case of ARM Processors This Peripheral is designed by the name of CoreSight Architecture. Now it has a number of components like ITM, DWT, STM, DAP etc. which collectively provides features of debug, Trace, Timestamp, Prolific Counters and many more. CoreSight Debug Architecture “The ARM Cortex M/R/A processor uses the CoreSight for on-chip Debug and Trace capabilities.” CoreSight Architecture is designed in a very modular way which has Number of Components and Units providing debug and trace solutions with high bandwidth for whole systems, including trace and monitor of the system bus. These Components can be categorized in following Sections: Control and Access Components à Configure, access, and control the generation of trace/Debug. They do not generate traces, nor process the trace data. Debug Access Port (DAP) Embedded Cross Trigger (ECT) Trace Sources-> Components which generate trace data. Embedded Trace Macrocell (ETM) Instrumentation Trace Macrocell (ITM) AHB Trace Macrocell (HTM) Flash Patch and Breakpoint unit (FPB) Data Watchpoint and Trace Unit (DWT) Program Trace Macrocell (PTM) System Trace Macrocell (STM) Embedded Logic Analyzer (ELA) Trace Sink -> Sinks are the endpoints for trace data on the SoC. Trace Port Interface Unit (TPIU) Trace Memory Controller (TMC) Serial Wire Output (SWO) Embedded trace Buffer (ETB) Trace Links-> provide Connection, triggering and flow of traced data between Source and Sink. Trace Funnel Trace Replicator ATB Bridge Debug and Trace Buses à The CoreSight systems use the following bus protocols to connect components together, and to enable integration in a SoC. AMBA Trace Bus (ATB). AMBA 3 Advanced Peripheral Bus (AMBA 3 APB). Advanced High-Performance Bus (AHB). AMBA Advanced extensible Interface (AXI) ARM licenses the different Components of CoreSight Architecture to the SoC manufacture vendors.According to the ARM Processor these Components vary like in Cortex -A72, Trace Source components ELA and STM are there whereas in Cortex M3/M4, Trace Source Components ELA and STM are not included in its Architecture.Same way-out Trace Sink Components also vary from ARM Processor to processor.Depending on these Units and Components used by vendors for their Processor design there can be changes in features available for trace and Debug. Debug Access Port (DAP) Enables the Debug Access between SoC and Host Debugger. Debug Ports are used to access External Debugger and Access Ports are used for on chip System Resources. Debug Port (DP) JTAG and SWD (+SWO pin – for trace) are the communication Protocols which can be used for Debug/Trace. Now for Connecting and having communication with MCU core to the host debugger (Stlinkv2), we need special Port (I/O pins) on the MCU as these protocols work at very high bandwidth and are directly in play with the Processor. This port is called Debug Port. There are 3 Debug port modules which are available in all ARM cortex M processors: SWJ-DP (Serial wire JTAG Debug Port) à Supports both Serial Wire and JTAG protocols SW-DP (Serial wire Debug Port) à Supports only Serial Wire Protocol. JTAG-DP (JTAG Debug Port)à Supports only the JTAG Protocol, available in older generations of ARM Processor and almost every Processor. Debug and Trace Buses & Access Port (AP) Access Port is a Port that connects the DP and the Components of the CoreSight Architecture. The CoreSight systems use the following bus protocols to connect components together, and to enable integration in a SoC. AMBA Trace Bus (ATB-AP) AMBA 3 Advanced Peripheral Bus (AMBA 3 APB) Advanced High-Performance Bus (AHB-AP) AMBA Advanced extensible Interface (AXI-AP) ARM Cortex M3/M4 Advanced High-Performance Bus (AHB-AP) is used for internal debug bus protocol to connect different Debug Components together. Embedded Cross Trigger The ECT is a modular component that supports the interaction and synchronization of multiple triggering events within a SoC. There are
Tackling the Changes of Retail Industry
The basic premise of search engine reputation management is to use the following three strategies to accomplish the goal of creating a completely positive first page of search engine results for a specific term…
Author