# CS/SS pin configuration

I am using an ATtiny861a and I want to enable it to use SPI. In doing this I need to assign not one, but two CS/SS pins in order to communicate with a radio and an external memory. Does the CS/SS pin need to be connected to an ADC pin or could it be connected to a AREF, PCINT, or OC1A/OC1B pin?

## 1 Answer

I believe you can use any GPIO pin as CS/SS. Keep in mind you will need a different pin for each slave device. For example say device0 SPI CS is connected to PORTD pin 5, and device1 SPI CS is connected to PORTD pin 6:

//init ports
DDRD  |= (1 << 5) | (1 << 6);    //sets PORTD bits 5 and 6 to output
PORTD |= (1 << 5) | (1 << 6);    //sets PORTD bits 5 and 6 to high (spi CS inactive)

//spi device0
PORTD &= ~(1 << 5);    //resets device0 CS (makes it active)
//SPI send/receive stuff here
PORTD |= (1 << 5);     //sets device0 CS (makes it inactive)

//spi device1
PORTD &= ~(1 << 6);    //resets device0 CS (makes it active)
//SPI send/receive stuff here
PORTD |= (1 << 6);     //sets device0 CS (makes it inactive)

• So the AREF, PCINT, and OC1A/OC1B pin are all GPIO pins? – Therusscher May 21 '15 at 17:57
• Yes, see datasheet (atmel.com/Images/…) on how to configure them and what pin functions you have to enable/disable to use them – jfri2 May 21 '15 at 18:03