SPI and chip select pins

Hi all…
I have a NANO w/328p on it I am trying to implement a Dallas/Maxim DS1305 RTC in SPI mode. I am trying to use D2 as my chip select pin instead of /SS. Every time I set “SPI.begin” I lose control of the chip select pin. I wrote a simple sketch that sits and toggles the pin (verified on my scope) along with print statements of ON/OFF. As soon as I add “SPI.begin” the pin stops responding (goes low)but yet displays On/OFF status. I have tried this with several different pins as well as another NANO, all with the same results. What am I missing here???

#include <SPI.h>

void setup() {
 // SPI.begin();  // stops toggling pin as soon as this is active
  pinMode(2, OUTPUT);

  // Start serial
  Serial.begin(9600);
  Serial.println("*Booting up");
}

void loop() {
  Serial.println("ON");
  digitalWrite(2, HIGH);

  delay(100);

  Serial.println("OFF");
  digitalWrite(2, LOW);
  delay(100);
}

have you connected the Dallas/Maxim DS1305 RTC to the nano? could the external circuit be holding D2 low?

Even though you are using D2 you need to have D10 set as OUTPUT. (NB. It is D10 on an Uno, I'm not sure if it is the same on a Nano).

...R

I believe SPI.Begin(); does that automatically along with setting MISO and MOSI

aa9gg:
I believe SPI.Begin(); does that automatically along with setting MISO and MOSI

You need to be certain.

And there is nothing to prevent later code from changing the mode, even though it should not.

...R