title: Read from a Slave with SPI
body: <p>I'm working with Atmega328p and I'm coding a program which can read and write from microcontroller and memory chip, </p>
  
  <p>I tried to write tab and it was written correctly, but when I want to read the tab from the memory chip, I receive number 255, I could not specialize this error! </p>
  
  <p>Can someone help me? </p>
  
  <pre><code>uint16_t read_SPI (uint16_t address){
      Slave_select;
      SPDR= address;
      while(!(SPSR &amp; (1&lt;&lt;SPIF)));
      Slave_deselect;
      return (SPDR);
  }
  
  
  void write_SPI (uint16_t address, uint16_t byte){
      Slave_select;
      SPDR=byte; 
      while(!(SPSR &amp; (1&lt;&lt;SPIF)));
      //address=SPDR; 
      /*SPI_tradeByte(0x02);
      chip_send16BitAdress(address);
      SPI_tradeByte(byte);*/
      Slave_deselect;
  }
  </code></pre>