Using toneAC library in conjunction with SPI library

Hi. I am using the atmega328p SPI library to control an MCP4151 digital potentiometer.
I am also controlling a speaker with the toneAC library which uses pins 9 & 10.

The SPI SS pin on the atmega328p is pin 10.

A have assigned the CS pin for the MCP4151 to some other pin.
So I am NOT using the SS pin (pin10) for the SPI, only for the speaker.

Question:
I have read that the SS pin MUST be configured as an output when using (initializing?) the SPI.
If the SS pin is configured as an INPUT the SPI on the micro will assume that it is a slave.
Will there be an issue with using toneAC with SPI since it will be pulsing pin 10.
Also at what point in time does the SS pin have to be configured as OUTPUT?
SPI.begin(); ?
Startup?
how about after sleep? does it have to be reinitialized?

And is I let's say configure as OUTPUT at SPI.begin(), can I then go ahead and use PIN 10 as an input or output? how about toneAC?

Can someone please clarify this. Thanks

If the ToneAC library is using pin 10 as an output, that satisfies the SPI requirement.

Make sure that pin 10 is set to output before you initialize the SPI connection.

SPI.begin sets pin 10 as output. pin 10 must be output all the time.
toneAC uses Timer1 output pins 9 and 10 (PWM). it is output.

Doesn't toneAC() or noToneAC() set it as input?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.