AnsweredAssumed Answered

NSS input not take into account on SPI SLAVE

Question asked by Bobino on Jan 18, 2017
Latest reply on Jan 19, 2017 by Imen D

I have a system with 1 STM32F407 and 3 STM32F401. The 407 is the master  of a communication with SPI with the 3 slaves. On the slave a use SPI in slave mode with DMA in RX/TX. On the slaves the input NSS is used in hardware mode. I have of course three GPIO on master which allow to select one slave after each other. When I try to ask a slave I receive it answer BUT all the three slave answer at the same time. It's like the slave do not take into account the NSS pin.

I have configured the system with STMCube.

I use the HAL library.

/* SPI2 init function */
void MX_SPI2_Init_STEPPER(void)
{

 

  hspi2.Instance = SPI2;
  hspi2.Init.Mode = SPI_MODE_SLAVE;
  hspi2.Init.Direction = SPI_DIRECTION_2LINES;
  hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
  hspi2.Init.NSS = SPI_NSS_HARD_INPUT;
  hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi2.Init.TIMode = SPI_TIMODE_DISABLED;
  hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
  hspi2.Init.CRCPolynomial = 10;
  HAL_SPI_Init(&hspi2);

 

}

 

void MX_DMA_Init_STEPPER(void)
{
  /* DMA controller clock enable */
  __HAL_RCC_DMA1_CLK_ENABLE();

 

  /* DMA interrupt init */
  HAL_NVIC_SetPriority(DMA1_Stream3_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA1_Stream3_IRQn);
  HAL_NVIC_SetPriority(DMA1_Stream4_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(DMA1_Stream4_IRQn);

 

}

 

 

    HAL_SPI_TransmitReceive_DMA(&SPI_HMI,(uint8_t *)&txAxisBuffer[0],(uint8_t *)&rxAxisBuffer[0],20);

 

Has someone a solution for me?

 

Thank you in advance.

Outcomes