title: MCU as SPI Slave, read data
body: <p>I have an master which i cant control it just sends clock with data. I congifured my stm32f4 as full-duplex slave. And i managed to synchronize them with HAL function:</p>
  
  <pre><code>HAL_SPI_TransmitReceive(&amp;hspi1, (uint8_t*)spi_buffer, (uint8_t *)spi_buffer, 16, 2000);  
        // receive 16 bytes then send them for debugg
  </code></pre>
  
  <p>Im sending from slave the bytes which i get from master, in purpose of debugging,
  and the data is same, so its perfectly synchronized and seems like slave reading all data master sends. Here is the images(sorry cant dowload it with stackoverflow cuz i low on points):</p>
  
  <ol>
  <li><a href="https://imgur.com/wa6rF5J" rel="nofollow noreferrer">https://imgur.com/wa6rF5J</a>  - ocsillo's image</li>
  <li><a href="https://imgur.com/a/ZVCPaNT" rel="nofollow noreferrer">https://imgur.com/a/ZVCPaNT</a> - zoomed up</li>
  </ol>
  
  <p>The problem is that i dont know how to read that data, its 16bytes which i need somehow to read without slowing the spi down. All my attempts to do that are failed. 
  Thw whole code are:</p>
  
  <pre><code>    int main(void)
  {
    /* USER CODE BEGIN 1 */
  
  
    /* USER CODE END 1 */
  
    /* MCU Configuration----------------------------------------------------------*/
  
    /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
    HAL_Init();
  
    /* USER CODE BEGIN Init */
  
    /* USER CODE END Init */
  
    /* Configure the system clock */
    SystemClock_Config();
  
    /* USER CODE BEGIN SysInit */
  
    /* USER CODE END SysInit */
  
    /* Initialize all configured peripherals */
    MX_GPIO_Init();
    MX_DMA_Init();
    MX_USB_DEVICE_Init();
    MX_SPI1_Init();
    /* USER CODE BEGIN 2 */
    /* USER CODE END 2 */
    /* Infinite loop */
    /* USER CODE BEGIN WHILE */
          uint8_t collect_bits[16] = {0};
          char string_array[21] = {0};
          uint8_t spi_buffer[16] ={0} ;
          uint8_t flag_when_start_print = 0;
          spi_buffer[0] = 5;
          uint8_t spi_transmit[16] = {0};
  
          HAL_SPI_Init(&amp;hspi1); //init spi
  
    while (1)
    {
    HAL_SPI_TransmitReceive(&amp;hspi1, (uint8_t*)spi_buffer, (uint8_t *)spi_buffer, 16, 2000);
    if (spi_buffer[0] == 0xFE) // just tring to catch 0xFE, doesnt work
  {   
      sprintf(string_array, "%X", spi_buffer[0]); // just simple convertation for PC output
  CDC_Transmit_FS((uint8_t*)string_array, sizeof(string_array));   // print result. }
      }
     }
  </code></pre>
  
  <p>The important fact that the beggining of the messge i want to catch is always starts with 0xFE0010, so after those bytes i need to read next 13bytes</p>