AnsweredAssumed Answered

SPI in Master Mode with NSS Hard Output

Question asked by Jim on Jul 7, 2017
Latest reply on Jul 8, 2017 by waclawek.jan

Hello, I interfaced STM3210E-EVAL with external RF Slave chip and trying to place a data in a slave register.

Ex data: 

Slave register address is 0xC0 and placing two bytes of data (0x00 and 0x12). For this I  configured SPI-1 as follows:

 

hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_MASTER;
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH; //SPI_POLARITY_LOW;
hspi1.Init.CLKPhase = SPI_PHASE_2EDGE; //SPI_PHASE_1EDGE;
hspi1.Init.NSS = SPI_NSS_HARD_OUTPUT;
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi1.Init.CRCPolynomial = 10;

 

bool SendSPIData(void)

{

rte = false;

aTxBuffer[0]= 0xC0; //RegisterAddr;
aTxBuffer[1]= 0x00;
aTxBuffer[2]= 0x12;

if(HAL_SPI_Transmit(&hspi1, (uint8_t*)aTxBuffer, 3, CBUS_ACK_TIMEOUT)!= HAL_OK)
       rte = false;
else
{
     rte = true;
     break;
  }

return rte;

}

 

Issues with this coding I am seeing: 

1. Couldn't able to toggle SS line as slave chip vendor suggested from High to low when clock and data present.

2. There is a long gap in between each byte transmission

 

Slave chip requires SPI data lines toggle as shown in following picture:

Appreciates any help on this.

RF Chip Suggested Waveform

Outcomes