How to listen only SPI communication as SPI slave

Hello all,
I want to listen communication between some CPU and SPI EEPROM. All I care is when CPU writing information to specific address only . I made some project for Nucleo F429ZI, one SPI SD card, for logging data, I2C for LCD to see what is going, they work fine. Also second SPI as SPI slave with no MISO.
So for now I’m receiving some data, only I do not understand how exactly SPI Slave work . Does “SPIdevice.receive()” use some buffer for all data of this receive and "SPIdevice.read() "only reads data from this buffer? How to clear this buffer? “SPIdevice.clear_transfer_buffer ()” does not work for slave.
Main simple SPI testing code is:

        int i=0;
    while (!btn) {
                 if(SPIdevice.receive()) {
                   printf("\r\nSPI receive.. %d",i);
                    fprintf(fp,"\r\nSPI data.  %d",i); //write to SD card
                  int v = SPIdevice.read();  
                   fprintf(fp," %X",v);
                   printf(" %X",v);
                   int v1 = SPIdevice.read();  
                   fprintf(fp," %X",v1);
                   printf(" %X",v1);
                   int v2 = SPIdevice.read();  
                   fprintf(fp," %X",v2);
                   printf(" %X",v2);
                   int v3 = SPIdevice.read();  
                   fprintf(fp," %X",v3);
                   printf(" %X",v3);
                  i++;
               }    

What I’m receiving is not always EEPROM control commands on every new receive like it must be by EEPROM datasheet. Maybe there is data from previous receive? Real data length of every communication is unknown and may be different in length.
How to read only maybe 5 first communication bytes of every data send-receive?

Hello,

I am sure the printfs in the loop cause your problems, because the printf is very slow function.

BR, Jan

Thank you,
I will try to move printf outside receive() loop. I’m not sure about time between communications…

BR Romas