On the Arduino Duemilanove and other ATmega168 / 328-based boards, the SPI bus uses pins 10 (SS), 11 (MOSI), 12 (MISO), and 13 (SCK). On the Arduino Mega, this is 50 (MISO), 51 (MOSI), 52 (SCK), and 53 (SS). Note that even if you're not using the SS pin, it must remain set as an output; otherwise, the SPI interface can be put into slave mode, rendering the library inoperative.
The DAC has no way to send data back to the atmega, so that pin will be connected to nothing. Can I use it for something else without screwing up my communications,
So how about pin 10?
When configured as a Master, the SPI interface has no automatic control of the SS line. Thismust be handled by user software before communication can start. When this is done, writing abyte to the SPI Data Register starts the SPI clock generator, and the hardware shifts the eightbits into the Slave. After shifting one byte, the SPI clock generator stops, setting the end ofTransmission Flag (SPIF). If the SPI Interrupt Enable bit (SPIE) in the SPCR Register is set, aninterrupt is requested. The Master may continue to shift the next byte by writing it into SPDR, orsignal the end of packet by pulling high the Slave Select, SS line.
Note that even if you're not using the SS pin, it must remain set as an output; otherwise, the SPI interface can be put into slave mode, rendering the library inoperative.
If SS is configured as an output, the pin is a general output pin which does not affect the SPI system.
const char * test = "Hello world"; SPI.begin (); char c; const char * p = test;// commence "transaction" digitalWrite(SS_PIN, LOW); // this is pin 10 in SPI.h // send test stringfor ( ; c = *p; p++) SPI.transfer (c);// end of transaction digitalWrite(SS_PIN, HIGH); SPI.end ();
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
email we just sent you.
Thank you for subscribing!
via Egeo 16