Posts

Showing posts from August, 2025

SPI (Serial Peripheral Interface)

Image
  What is SPI ? SPI (Serial Peripheral Interface) is a synchronous , full-duplex communication protocol used to transfer data between a master (e.g., microcontroller) and one or more slaves (e.g., sensors, memory chips). SPI uses 4 main lines : Line Full Name                 Direction Purpose MOSI      Master Out Slave In          Master → Slave          Master sends data to slave MISO      Master In Slave Out         Slave  → Master           Slave sends data to master SCLK      Serial Clock         Master → Slave          Clock signal generated by master SS      Slave Select         Master → Slave          Selects which slave to talk to SPI Communication Cha...

UART (Universal Asynchronous Receiver/Transmitter) :

Image
   What is UART? UART (Universal Asynchronous Receiver/Transmitter) is a hardware communication protocol used for serial communication between two devices. It is simple, widely used, and requires only two wires : TX (Transmit) RX (Receive) UART Communication Characteristics : Asynchronous : No shared clock between devices. Baud Rate : Both devices must agree on the speed (e.g., 9600, 115200 bits/sec). Framing : Each byte is wrapped with a start bit and stop bit . Optional Parity : For error checking. UART Data Frame Format : Start Bit    Data Bits (5-8)    Parity Bit (Optional)   Stop Bit(s) 0 e.g. 01100001            e.g. 0      1 void UART_init(unsigned int baud) {     unsigned int ubrr = F_CPU / 16 / baud - 1;     UBRR0H = (ubrr >> 8);     UBRR0L = ubrr;     UCSR0B = (1 << RXEN0) | (1 << TXEN0); // Enable RX and TX   ...