bug on CS line using SPI library


I encountered a bug when using the SPI library in the mode where the chip select (or slave select) pin is automatically treated by the library.
The problem is that during the SPI communication the voltage on the CS pin is brought from 3.3V down to only 1.6V and not to 0V as normally.
I use the following sample code (IDE 1.5.2):

#include <SPI.h>
const int CS = 4;         

void setup() {
  pinMode(CS, OUTPUT);

void loop() {
  SPI.transfer(CS, 0);

I identified the problem being caused by the "pinMode(CS, OUTPUT);" command. Removing this command prior to the SPI initialization also removes this bug. The voltage drops fully down to 0V during the communication.

This problem occurs only when using pins 10 (SPI-CS0) and 4 (SPI-CS1) as chip select. The pin 52 (SPI-CS2) works fine with the additional command to set the pin mode as OUTPUT. I didn't check in the library itself where this bug comes from but I think it should be fixed since it can cause serious troubles for SPI communications.

I know that the "pinMode(CS, OUTPUT);" command is somewhat unnecessary in the case of using the SPI library in that way but I think it is kind of intuitive to nevertheless define the pin mode for the CS pin as OUTPUT. So I would expect that other people might run into the same problem.

Could anyone verify this behaviour on his DUE?


may you file an issue on github so this is not lost?

link also this topic on the description!