SPI Slave mode using DMA and soft NSS
I'm trying to transmit some data using DMA as a slave SPI device. I'm sending 8 byte but the peripheral always gives me 9 byte on the MISO line (first byte twice). The Master NSS is connected to a GPIO input (SPI_ENABLE) using external interrupt Mode with Rising/Falling edge trigger detection. Within the GPIO interrupt routine I set or clear the SPI_CR1_SSI bit as follows.
if (0 == pUSBPD->spi_nss.Get())
{
hspi->Instance->CR1 &= ~SPI_CR1_SSI;
flag_USBPD_SPI_Active = true;
}
else
{
hspi->Instance->CR1 |= SPI_CR1_SSI;
flag_USBPD_SPI_Active = false;
}
the data transmitted using DMA is:
uint8_t txBuf[8] = { 0x81, 0x01, 0x80, 0xFF, 0x55, 0xAA, 0xAA, 0xAA };
The attachment shows the result. I have no idea why the first byte is send twice. Does anyone have any idea
Thanks in advance.