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