AnsweredAssumed Answered

STM32F0 SPI slave mode issue TXRX HAL

Question asked by Quigley.Robert.001 on Jan 13, 2016

I'm using an STM32F0306 in SPI slave mode *** a sub processor in a project.
I used cubeMX to generate the initialization and have added functions in Keil v473.

The ST part is in slave mode, 8 bit motorola, LSB first , clock pol low, 2nd edge data

01.void MX_SPI1_Init(void)
04.  hspi1.Instance = SPI1;
05.  hspi1.Init.Mode = SPI_MODE_SLAVE;
06.  hspi1.Init.Direction = SPI_DIRECTION_2LINES;
07.  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
08.  hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
09.  hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
10.  hspi1.Init.NSS = SPI_NSS_SOFT;
11.  hspi1.Init.FirstBit = SPI_FIRSTBIT_LSB;
12.  hspi1.Init.TIMode = SPI_TIMODE_DISABLED;
13.  hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
14.  hspi1.Init.CRCPolynomial = 7;
15.  hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
16.  hspi1.Init.NSSPMode = SPI_NSS_PULSE_DISABLED;
17.  HAL_SPI_Init(&hspi1);

When the main processor receives a flag, it pulls the CS low, and sends a packet and the clock pulses to drive the transfer. I'm sending 28 bytes but the last three bytes aren't transmitting and then on the next packet the FIFO flushes these out before my data. This is received as a corrupt transfer on my main processor. 
1.for(uint8_t j=0;j<28;j++){
2.      //TX_Hold=getDummyElement(j); //for Debug
3.      TX_Hold=getFT5306BuffElement(j);
4.      HAL_SPI_TransmitReceive(&hspi1,pTX, (pRecv+j), 1,1);
5.   }

first byte should be 0x80
1.uint8_t SPI_Buff[28]={  0x80, 0x2a, 0x2a, 0x2c,/*FIXED*/
2.                        0x00, 0x00,
3.                        0x79, 0x7F, 0x7F, 0x7F, /*touch1*/
4.                        0x79, 0x7F, 0x7F, 0x7F, /*touch2*/
5.                        0x79, 0x7F, 0x7F, 0x7F, /*touch3*/
6.                        0x79, 0x7F, 0x7F, 0x7F, /*touch4*/
7.                        0x79, 0x7F, 0x7F, 0x7F, /*touch5*/
8.                        0x63};

but as can be seen, the data is shift three packets and clearing the DR reg does not fix the issue.SPI_Screen.PNG

Any hints would be appreciated.