---
title: "Send 2Bytes SPI command when 2 SPI slaves"
url: "https://maker.wiznet.io/forum/11478"
markdown_url: "https://maker.wiznet.io/forum/11478/md"
type: "Forum topic"
category: "IO Modules"
author: "JulesMhz"
created: "2015-11-25T10:41:02+09:00"
last_activity: "2017-05-04T08:37:36+09:00"
language: "en"
views: 940
replies: 0
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Send 2Bytes SPI command when 2 SPI slaves

## Question

Asked by JulesMhz on 2015-11-25 in IO Modules.

Hello,

I’m using a Teensy 3.2 together with WIZ820io, and I use Ethernet library for W8200 ([github.com/PaulStoffregen/Ethernet](https://github.com/PaulStoffregen/Ethernet)), and I’m able to send UDP packets.

My problem comes when I use a second SPI slave on my teensy (the first SPI slave is the WIZ820io), for controling the second SPI slave, I need to send/receive 2Bytes command like that :

`digitalWrite(CSPin, LOW); SPI.transfer (0x10); SPI.transfer (ControlReg >> 8); SPI.transfer (ControlReg & 0xFF); digitalWrite(CSPin, HIGH);`

This code works fine when I don’t use WIZ820io, but when I start it, my second slave does not respond.

Moreover, if I send 1Byte to my second slave, it works fine, for example :

`digitalWrite(CSPin, LOW); SPI.transfer (0x07); SPI.transfer (div); rxw=SPI.transfer(0); digitalWrite(CSPin, HIGH);`

Here is my setup code :

[code]pinMode(TESTPin, OUTPUT);
digitalWrite(TESTPin, LOW);

pinMode (CSPin, OUTPUT);
digitalWrite (CSPin, HIGH);

pinMode (CSNETPin, OUTPUT);
digitalWrite (CSNETPin, HIGH);

Ethernet.begin(mac,ip);
Udp.begin(localPort);

delay(2500);

SPI.setMOSI(MOSIpin);
SPI.setMISO(MISOpin);*/
SPI.begin();
SPI.setDataMode(SPI_MODE0);
SPI.setBitOrder(MSBFIRST);

pinMode(INTERPin, INPUT); [/code]

Thank you for your support.

Cheers.
Julien.

---

Source: https://maker.wiznet.io/forum/11478
