WIZnet Developer Forum

Send 2Bytes SPI command when 2 SPI slaves

Hello,

I’m using a Teensy 3.2 together with WIZ820io, and I use Ethernet library for W8200 (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.

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.