Arduino pin 10 for PWM whilst SPI slave

arduinoatmegaavrpwmspi

I need to use my Arduino Uno (ATmega328) as an SPI slave and have still have access to at least 5 PWM pins. The only issue is that this means I will have to use pin 10 (Slave select / PB2) as the fifth PWM pin because pin 11 (MOSI / PB3) is definitely not an option and it appears that the moment I initiate SPI in slave mode it stops PWMing pin 10 and simply turns it off. Would it be possible to somehow restore PWM access to this pin? I do not need this pin for slave select, I can rather use a plain IO and just attach and detach SPI upon interrupts from it thereby emulating slave select.

Best Answer

The ATmega328p datasheet section 18.3.1 states

the Slave Select (SS) pin is always input.

where using the SPI in slave with out a SS would likely have issues with sync'ing the first bit of the data. Where if that is not a problem then I would suggest that perhaps a Leonardo would solve your problem. It has 8 PWM's, none on the SPI. Whereas its SPI SS is wired to the RXLED and not to a header. Otherwise the Mega would have all what you want.