Microchip | The Embedded Control Solutions Company Register Login
Browse All
Microchip Technology
 305 Code Snippets

CE138 - Using 2 SPI Slave Peripherals with one SPI module

Microchip Technology

This code example shows using the SPI module in conjunction with 2 GPIO pins to communicate with 2 different slave devices.

About this Code Example

1. Code Example Description:
----------------------------
This code example shows using the SPI module in conjunction with 2 GPIO pins to communicate with 2 different slave
devices.  The concept is that the GPIO are the slave selects for the individual devices, but the SCL, SDI and SDO are shared between the two processors.  This is also scalable up to n devices, where your only limitation is the bus bandwidth on the SPI bus and the number of GPIO lines at your disposal.

Slave Select1 ---|                                     |---------------------------------------------------------
                         |____________________|

Slave Select2 ---------------------------------------------|                                                        |-----------------
                                                                         |_______________________________|

SCLK   xxxxxxxxxx |-| |-| |-| |-| |-| |-| |-| |-| xxxxxxxxxx |-| |-| |-| |-| |-| |-| |-| |-| xxxxxxxxxx
           xxxxxxxxxx_| |_| |_| |_| |_| |_| |_| |_| |_xxxxxxxxxx_| |_| |_| |_| |_| |_| |_| |_| |_xxxxxxxxxx

SDO    xxxxxxxxxx d7  d6  d5  d4  d3  d2  d1  d0  xxxxxxxxxx d7  d6  d5  d4  d3  d2  d1  d0  xxxxxxxxxx

The code alternates between sending data from one device to another and mixed.

Categories

Release History

  • Apr 19, 2012

    Version: 1.0.0

    New

Download Contact the Developer

*Required Fields

  • Current Version:1.0.0
  • Created:Apr 19, 2012
  • Updated:Feb 26, 2015
  • Downloads:2508
  • MPLAB Version:v8.xx or higher
  • C Compiler:C30 v3.00 or higher
  • Development Tools:Explorer 16 Demo board
  • Supported Devices:dsPIC33FJ256GP710 or dsPIC33Fxxxx

Corporate News

Resources

Stay Connected

Stay up to date with the latest news from Microchip Technology.