Device conflict using SPI interface

  #include  <SD.h>              //  only here for FreeRam function  uses about 750 bytes

Isn't that comment complete nonsense?

      if (b==2)
        b=B00000010;
      else if (b==1)
        b=B00000001;

If b is 2, set b to 2. If b is 1, set b to 1.

Exactly why is THAT necessary?

What RTC are you using? Most are I2C devices. If using the SPI RTC causes problems, get an I2C RTC.