title: STM32F4 HAL SPI TransmitReceive DMA Rx buffer being written to Tx buffer
body: <p>I am communicating between an STM32F4 (master) and an SPI device (slave).
  Communicating has been established I am debugging everything with a logic analyzer.</p>
  <p>Datasize is set to 8 bit and I am transmitting and receiving 4x 8-bit words.
  Clock is set to /8 prescaler (roughly 5MHz in my case).</p>
  <p>My Rx/Tx buffers are declared (Tx buffer is fixed):</p>
  <pre><code>uint8_t spi_dma_tx_[4] = {0xB2, 0x00, 0x00, 0x00};
  uint8_t spi_dma_rx_[4] = {0x00, 0x00, 0x00, 0x00};
  </code></pre>
  <p>After setting CS pin low, I am using this to initiate transfer:</p>
  <pre><code>HAL_GPIO_WritePin(spi_cs_port_, spi_cs_pin_, GPIO_PIN_RESET);
  HAL_SPI_TransmitReceive_DMA(hw_config_.spi, (uint8_t*)spi_dma_tx_, (uint8_t*)spi_dma_rx_, 4);
  </code></pre>
  <p>Data from the SPI device is processed after this call back:</p>
  <pre><code>void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi) {
      tero-&gt;prd_.spi_cb();
  }
  </code></pre>
  <p>which does something like this:</p>
  <pre><code>void prd::spi_cb() {
      HAL_GPIO_WritePin(spi_cs_port_, spi_cs_pin_, GPIO_PIN_SET);
      //data reconstruction using stuff in spi_dma_rx[]
      ../.. //sparing you the details here
  }
  </code></pre>
  <p>In summary, once spi_dma_tx[] is declared, it's never played with.
  Data in spi_dma_rx[] is extracted for reconstruction inside the spi callback function.</p>
  <p>What I see on the logic analyzer is puzzling me:</p>
  <p>On MOSI: 0xB2, 0x00, 0xB2, 0xCA
  on MISO: 0xB2, 0xCA, 0x17, 0xBE (the 3 bytes following 0xB2 are actual data, which will change all the time, 0xB2 is confirmation that the command has been properly understood by the device - i.e. no problem on MISO)</p>
  <p>Notes:</p>
  <p>Everything on MISO is as expected and the device seems to be working as intended.
  On MOSI however, I should have: 0xB2, 0x00, 0x00, 0x00 - nothing else, it should be that ALL the time. (MISO output 0xB2 on the first byte is also normal, as confirmation the command was received properly).
  However, the first 2 bytes on MISO are systematically copied to third and fourth byte of MOSI, systematically.</p>
  <p>Has anyone ever seen anything like this?</p>
  <p>I would really like to understand what's going on. Searched through my entire project and literally spi_dma_tx is never called anywhere outside of the variable declaration and the HAL_SPI_TransmitReceive_DMA(..) function.</p>
  <p>Cheers</p>