1
\$\begingroup\$

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?

\$\endgroup\$
2
\$\begingroup\$

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)
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ So the AREF, PCINT, and OC1A/OC1B pin are all GPIO pins? \$\endgroup\$ – Therusscher May 21 '15 at 17:57
  • \$\begingroup\$ Yes, see datasheet (atmel.com/Images/…) on how to configure them and what pin functions you have to enable/disable to use them \$\endgroup\$ – jfri2 May 21 '15 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.