Skip to main content
jzotes
Associate
September 22, 2016
Solved

SPI NSS do not change. HAL libraries

  • September 22, 2016
  • 2 replies
  • 819 views
Posted on September 22, 2016 at 12:51

Hi all;

I am trying to comunicate with an external flash memory with my STM32F429. I can see my signals in the oscilloscope . I see how my microcontroler starts the clock and write to the bus but the NSS signal do not change. It is always at LOW level. This is a problem with this flash beacuse it uses NSS signal to sincronice data.

I have configure the SPI5 chanel with the following code:

  hspi5.Instance = SPI5;

  hspi5.Init.Mode = SPI_MODE_MASTER;

  hspi5.Init.Direction = SPI_DIRECTION_2LINES;

  hspi5.Init.DataSize = SPI_DATASIZE_8BIT;

  hspi5.Init.CLKPolarity = SPI_POLARITY_LOW;

  hspi5.Init.CLKPhase = SPI_PHASE_1EDGE;

  hspi5.Init.NSS = SPI_NSS_HARD_OUTPUT;

  hspi5.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128;

  hspi5.Init.FirstBit = SPI_FIRSTBIT_MSB;

  hspi5.Init.TIMode = SPI_TIMODE_DISABLE;

  hspi5.Init.CRCCalculation = SPI_CRCCALCULATION_ENABLE;

  hspi5.Init.CRCPolynomial = 7;

  if (HAL_SPI_Init(&hspi5) != HAL_OK)

 

I understand that if I set NSS as a Hardware Output SPI peripheal is going to manage it correctly but it ramains in LOW state. I wanto to see the change from HIG to LOW state so the flash start to read or write into the com lines.

Could anybody help me?? I repeat that te SPI is working but if there is not edge in the NSS bit.

#!spi-!stm32f429-!externalflash
    This topic has been closed for replies.
    Best answer by slimen
    Posted on September 22, 2016 at 14:19

    Hi jzotes,

    The reference manual

    http://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf

     says that: 

    ''NSS output enabled (SSM = 0, SSOE = 1)

    This configuration is used only when the device operates in master mode. TheNSS signal is driven low when the master starts the communication and is keptlow until the SPI is disabled. ''

    You may assign NSS as GPIO CS, will resolve this issue.

    Regards

    2 replies

    slimen
    slimenBest answer
    Visitor II
    September 22, 2016
    Posted on September 22, 2016 at 14:19

    Hi jzotes,

    The reference manual

    http://www.st.com/content/ccc/resource/technical/document/reference_manual/3d/6d/5a/66/b4/99/40/d4/DM00031020.pdf/files/DM00031020.pdf/jcr:content/translations/en.DM00031020.pdf

     says that: 

    ''NSS output enabled (SSM = 0, SSOE = 1)

    This configuration is used only when the device operates in master mode. TheNSS signal is driven low when the master starts the communication and is keptlow until the SPI is disabled. ''

    You may assign NSS as GPIO CS, will resolve this issue.

    Regards

    jzotes
    jzotesAuthor
    Associate
    September 22, 2016
    Posted on September 22, 2016 at 17:06

    Thanks for your reply. I have disabled de NSS signal and configure that pin as GPIO. The device is talking with my STM32 without problems.  Thank you very much.