Summary of Lecture 45 : PIC Serial Communication using Serial Peripheral Interface (SPI)
This experiment establishes serial communication between two PIC16F877A microcontrollers using the Serial Peripheral Interface (SPI). The master reads 8-bit digital input from Port-B and transmits it to the slave, which outputs the value to its own Port-B. Communication utilizes three lines: SDO, SDI, and SCK. The master controls the clock and initiates transmission via the SSPBUF register, while the slave uses interrupts to receive data and update its output port.Parts used in the PIC16F877A SPI Communication Project:
- PIC16F877A Microcontroller (Master)
- PIC16F877A Microcontroller (Slave)
- Port-B Input (Master)
- Serial Data Out (SDO)
- Serial Data In (SDI)
- Serial Clock (SCK)
- SSPCON Register
- SSPBUF Register
- SSPIF Flag
Objective
To establish serial communication between two PIC16F877A microcontrollers
| Description |
| In this experiment, 8-bit digital input is applied at Port-B to one of the PIC16F877A microcontroller which acts as a master in serial communication. The input value is transmitted by the master serially via Serial Peripheral Interface (SPI) to the second PIC16F877A microcontroller, which acts as a slave. The slave then outputs the value to its Port-B. Following three lines are used for serial communication |
|
The SDO for master acts as SDI for slave and vice-versa. Serial clock is invariably provided by the master. The SPI communication settings are done using SSPCON register.
|
| Transmission is initiated by the Master by writing to the SSPBUF register. When transfer is complete, Synchronous Serial Port Interface Flag (SSPIF) will be set. This can cause an interrupt if peripheral interrupt is enabled. |
Assembly Code
|
|
| Mainline: |
|
|
|
|
Mainline: bsf STATUS, RP0 ; Bank 1
|
| loop: goto loop ; Infinite loop |
|
For more detail: Lecture 45 PIC Serial Communication using Serial Peripheral Interface (SPI) Schematic
Quick Solutions to Questions related to PIC16F877A SPI Communication Project:
- What is the objective of this experiment?
To establish serial communication between two PIC16F877A microcontrollers. - How does the master initiate transmission?
The master initiates transmission by writing to the SSPBUF register. - Which lines are used for serial communication?
The project uses Serial Data Out, Serial Data In, and Serial Clock. - Does the slave provide the serial clock?
No, the serial clock is invariably provided by the master. - What happens when the transfer is complete?
The Synchronous Serial Port Interface Flag will be set. - Can the completion of a transfer cause an interrupt?
Yes, this can cause an interrupt if peripheral interrupt is enabled. - What value is transmitted by the master?
The master transmits the 8-bit digital input value applied at Port-B. - Where does the slave send the received value?
The slave outputs the value to its Port-B.
Related projects
PIC16F877 Driving LCD in 4-Bit Mode using PIC16F877 with Proteus Simulation
Introduction This microcontroller project shows how a PIC16F877 can drive an LCD display using 4-bit mode inside a Proteus simulation.The project demonstrates...
Programmers & ICSP · PIC16F877AEPE PIC/LCD Demo using PIC16F877 with Proteus Simulation
IntroductionThe EPE PIC/LCD Demo is a classic microcontroller project that demonstrates how a PIC16F877 can fully control a PG12864F graphical LCD.Designed as...
Motors & Robotics · PIC16F877AEfficient Sun-Following Robot: A Solar Tracker with Microcontroller Control
Abstract The impending global challenge of dwindling non-renewable fuel resources underscores the urgency of transitioning towards renewable energy alternatives like solar power....
Communication & Interfacing · PIC18F4520CAN FD Node based on a PIC18 Microcontroller
The introduction sets the stage for an embedded systems project that involves developing a Embedded C CAN FD project using the MCP2517FD...
Communication & InterfacingLAN9662 Gigabit Switch: Optimized for Industrial Ethernet
Introduction It should come as little surprise therefore that one element of what is now more commonly referred to in some circles...
Communication & InterfacingPIC Microcontroller: Fundamentals & Applications for Students
Introduction Microcontrollers are the key components in the embedded systems market. A variety of embedded systems was formed and developed after the...

