SPI transfer problems

Hi guys, I am working on a project that uses an ATtiny85 and a MCP4151 digital potentiometer via SPI. I am using a rotary encoder to shift the potentiometer level. But I am getting some weird results, first of all the encoder only registers in one direction and when it does register the level change is really awkward. The signal goes from 255 to 0 than back sometimes something in between. The connections I made are the following:
MCP4151 <---> ATtiny85
CS(pin1) - pin 2 (SS pin(not an actual SS pin))
SI(pin3) - pin 6 (MOSI pin)
SCK(pin2) - pin 7 (SCK pin)

The encoder is on pins 1 and 3 on the tiny85. I also used the code provided from Gammon Forum : Electronics : Microprocessors : SPI - Serial Peripheral Interface - for Arduino by Nick Gammon, since as I figured out the tiny does not support the Arduino SPI.h library and in fact it has "pretend" SPI. So with his code and some tweaking around I came up with this masterpiece, which obviously doesn't work as expected:

namespace tinySPI 
  {

  const byte DI   = 0;  // D0, pin 5  Data In
  const byte DO   = 1;  // D1, pin 6  Data Out (this is *not* MOSI)
  const byte USCK = 2;  // D2, pin 7  Universal Serial Interface clock
  const byte SS   = 3;  // D3, pin 2  Slave Select
  
  void begin ()
    {
    digitalWrite (SS, HIGH);  // ensure SS stays high until needed
    pinMode (USCK, OUTPUT);
    pinMode (DO,   OUTPUT);
    pinMode (SS,   OUTPUT);
    pinMode (DI,   INPUT);
    USICR = bit (USIWM0);  // 3-wire mode
    }  // end of tinySPI_begin
    
  // What is happening here is that the loop executes 16 times.
  // This is because the 4-bit counter in USISR is initially zero, and then
  // toggles 16 times until it overflows, thus counting out 8 bits (16 toggles).
  // The data is valid on the clock leading edge (equivalent to CPHA == 0).
  
  byte transfer (const byte b)
    {
    USIDR = b;  // byte to output
    USISR = bit (USIOIF);  // clear Counter Overflow Interrupt Flag, set count to zero 
    do
      {
      USICR = bit (USIWM0)   // 3-wire mode
            | bit (USICS1) | bit (USICLK)  // Software clock strobe
            | bit (USITC);   // Toggle Clock Port Pin
      } while ((USISR & bit (USIOIF)) == 0);  // until Counter Overflow Interrupt Flag set
      
    return USIDR;  // return read data
    }    // end of tinySPI_transfer

  };  // end of namespace tinySPI
 
#define encoder0PinA  5 //pin 1
#define encoder0PinB  4 //pin 3

volatile unsigned int encoder0Pos = 0;

  void setup (void)
  {
  tinySPI::begin ();
  pinMode(encoder0PinA, INPUT); 
  digitalWrite(encoder0PinA, HIGH);       // turn on pullup resistor
  pinMode(encoder0PinB, INPUT); 
  digitalWrite(encoder0PinB, HIGH);       // turn on pullup resistor

  attachInterrupt(0, doEncoder, CHANGE);  // encoder pin on interrupt 

  }  // end of setup

void loop (void)
  {
  

  int channel=0;
  int level=0;
  {
    if (digitalRead(encoder0PinA) == digitalRead(encoder0PinB))
    { 
     digitalPotWrite (channel, encoder0Pos); //Sets the level of the potentiometer to the level of the encoder in this case 1 up
    }
    else 
    {
     digitalPotWrite(channel,encoder0Pos); //Sets the level of the potentiometer to the level of the encoder in this case 1 down
    }
  }
}
  
void doEncoder() {

  if (digitalRead(encoder0PinA) == digitalRead(encoder0PinB)) {
    if (encoder0Pos < 255) encoder0Pos++;
  } else {
    if (encoder0Pos > 0) encoder0Pos--;
  }

}
  void digitalPotWrite(int address, int value) {
  // take the SS pin low to select the chip:
  digitalWrite(tinySPI::SS,LOW);
  //  send in the address and value via SPI:
  tinySPI::transfer(address);
  tinySPI::transfer(value);
  // take the SS pin high to de-select the chip:
  digitalWrite(tinySPI::SS,HIGH); 
}

Although I don't really understand all of it, I am pretty sure it should work. I did the code on Arduino Uno and it worked fine, with the SPI.h library of course.
I build the project on a breadboard, and I have seen some signal trouble with it before, so I don't think that is the problem.
To conclude I will ask if someone could point me to my mistake and/or has some idea where the problem is, please write it down.
Thanks!

Which Tiny framework do you use? (tiny or attiny?)

What's the output of your Tiny? Do you get activity on the SPI pins? Try setting encoderPos0 to 127 at start to have a visible output signal to check with the logic analyzer.

Hi, I am using the ATtiny85, and the core for the arduino is ATtiyn85 internal 8MHz oscillator BOD disabled (hope that helps). And for the SPI transfer, the code is supposed to set the level at 0 but it starts at 255, and when I rotate the encoder it changes from 0 to 255 and back sometimes it goes in between. I don't have a logic analyzer and I could only watch with a voltmeter at the digital potentiometer. But since it changing I believe I do get signal from the SPI pins.