Q:
                    
                
                                    What is the difference between the I2c and SPI communication Protocols?
belongs to collection: Embedded C interview questions and answers (2022)
Embedded C interview questions and answers (2022)
- What is the difference between C and embedded C?
 - What is the volatile keyword?
 - What is the use of volatile keyword?
 - What is the difference between the const and volatile qualifiers in C?
 - Can a variable be both constant and volatile in C?
 - Can we have a volatile pointer?
 - The Proper place to use the volatile keyword?
 - What is ISR?
 - Can we pass any parameter and return a value from the ISR?
 - What is interrupt latency?
 - How do you measure interrupt latency?
 - How to reduce interrupt latency?
 - Is it safe to call printf() inside Interrupt Service Routine (ISR)?
 - Can we put a breakpoint inside ISR?
 - What is the difference between an uninitialized pointer and a null pointer?
 - What are the causes of Interrupt Latency?
 - Can we use any function inside ISR?
 - What is a nested interrupt?
 - What is NVIC in ARM Cortex?
 - Can we change the interrupt priority level of Cortex-M processor family?
 - Why “C” language mostly preferred than assembly language?
 - What is the start-up code?
 - What are the start-up code steps?
 - Infinite loops often arise in embedded systems. How do you code an infinite loop in C?
 - How to access the fixed memory location in embedded C?
 - Difference between RISC and CISC processor?
 - What is the stack overflow?
 - What is the cause of the stack overflow?
 - What is the difference between the I2c and SPI communication Protocols?
 - What is the difference between Asynchronous and Synchronous Communication?
 - What is the difference between RS232 and RS485?
 - What is the difference between Bit Rate and Baud Rate?
 - What is segmentation fault in C?
 - What are the common causes of segmentation fault in C?
 - What is the difference between Segmentation fault and Bus error?
 - Size of the integer depends on what?
 - Are integers signed or unsigned?
 - What is a difference between unsigned int and signed int in C?
 - What is the difference between const and macro?
 - How to set, clear, toggle and checking a single bit in C?
 - What will be the output of the below C program?
 - Write a program swap two numbers without using the third variable?
 - What will be the output of the below C program?
 - What is meant by structure padding?
 - What is the endianness?
 - What is big-endian and little-endian?
 - Write a C program to check the endianness of the system
 - How to Convert little-endian to big-endian vice versa in C?
 - What is static memory allocation and dynamic memory allocation?
 - What is the memory leak in C?
 - What is the output of the below C code?
 - What is the output of the below C code?
 - What is the difference between malloc and calloc?
 - What is the purpose of realloc( )?
 - What is the return value of malloc (0)?
 - What is dynamic memory fragmentation?
 - How is the free work in C?
 - What is a Function Pointer?
 - How to declare a pointer to a function in C?
 - Where can the function pointers be used?
 - Write a program to check an integer is a power of 2?
 - What is the output of the below code?
 - What is the output of the below code?
 - Write a program to count set bits in an integer?
 - What is void or generic pointers in C?
 - What is the advantage of a void pointer in C?
 - What are dangling pointers?
 - What is the wild pointer?
 - What is a NULL pointer?
 - What are the post-increment and decrement operators?
 - Which one is better: Pre-increment or Post increment?
 - How will you protect a pointer by some accidental modification with the pointer address?
 - How to use a variable in a source file that is defined in another source file?
 - Can static variables be declared in a header file?
 - What is the difference between pass by value by reference in c and pass by reference in c?
 - What is a reentrant function?
 - What is the inline function?
 - What is the advantage and disadvantage of the inline function?
 - What is virtual memory?
 - How can you protect a character pointer by some accidental modification with the pointer address?
 - Consider the two statements and find the difference between them?
 - Can structures be passed to the functions by value?
 - What are the limitations of I2C interface?
 - What is the Featured of CAN Protocol?
 - What is priority inversion?
 - What is priority inheritance?
 - Significance of watchdog timer in Embedded Systems?
 - What Is Concatenation Operator in Embedded C?
 
                        
        
    
C programming
Answer:
In the embedded system, I2C and SPI both play an important role. Both communication protocols are the example of synchronous communication but still, both have some important differences.
The important difference between the I2C and SPI communication protocol.
- I2C supports half-duplex while SPI is full-duplex communication.
 
- I2C requires only two-wire for communication while SPI requires three or four-wire for communication (depends on requirement).
 
- I2C is slower as compared to the SPI communication.
 
- I2C draws more power than SPI.
 
- I2C is less susceptible to noise than SPI.
 
- I2C is cheaper to implement than the SPI communication protocol.
 
- I2C work on wire and logic and it has a pull-up resistor while there is no requirement of a pull-up resistor in case of the SPI.
 
- In I2C communication we get the acknowledgment bit after each byte, it is not supported by the SPI communication protocol.
 
- I2C ensures that data sent is received by the slave device while SPI does not verify that data is received correctly.
 
- I2C supports multi-master communication while multi-master communication is not supported by the SPI.
 
- One great difference between I2C and SPI is that I2C supports multiple devices on the same bus without any additional select lines (work based on device address) while SPI requires additional signal (slave select lines) lines to manage multiple devices on the same bus.
 
- I2C supports arbitration while SPI does not support the arbitration.
 
- I2C support the clock stretching while SPI does not support the clock stretching.
 
- I2C can be locked up by one device that fails to release the communication bus.
 
- I2C has some extra overhead due to start and stop bits.
 
- I2C is better for long-distance while SPI is better for the short distance.
 
- In the last I2C developed by NXP while SPI by Motorola.
 
need an explanation for this answer? contact us directly to get an explanation for this answer