2017-11-14 01:47 AM
Hello there,
with my STM32F103, I'm working with the M25P40 SPI flash memory.
With cube32Mx I configured the SPI3 with Chip Select (NSS) hardware and I perform Read/Write/WriteRead operation with Interrupt.
My problem regards the NSS, in particular the NSS signal stay low after the read operation end and the:
are never invoked.
Looking the signal with Saleae Logic Analazer, I saw that NSS signal stay low.
Instead, theHAL_SPI_TxCpltCallback is invoked.
This is the SPI3 initialization code generated by CubeMx:
hspi3.Instance = SPI3;
hspi3.Init.Mode = SPI_MODE_MASTER;
hspi3.Init.Direction = SPI_DIRECTION_2LINES;
hspi3.Init.DataSize = SPI_DATASIZE_8BIT;
hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi3.Init.NSS = SPI_NSS_HARD_OUTPUT;
hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi3.Init.TIMode = SPI_TIMODE_DISABLE;
hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi3.Init.CRCPolynomial = 10;�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
I don't know how to resolve this issue.
Thanks in advance!
#interrupt #spi-write-and-read #flash-memory #stm32f1032017-11-14 02:45 AM
That's how it's supposed to work - read the RM.
If you want framing, you have to do it 'manually'.
JW
2017-11-14 03:47 AM
Hi Jan,
thank for the reply but frankly I don't understand your reply.
Could you please add more details?
2017-11-14 05:08 AM
RM0008, SPI chapter, Slave select (NSS) pin management subchapter:
The NSS signal is driven low when the master starts the communication and is kept
low until the SPI is disabled.If you want to set the pin to 0 before communication starts and to 1 after communication ends, you have to set it as GPIO and write the code to manipulate it.
JW
2017-11-14 05:36 AM
Thanks for the detailed explanation.
My question is: could be the HAL_SPI_RxCpltCallback related to the NSS signal?
I'm in trouble with the
HAL_SPI_RxCpltCallback, that is never invoked.
This is what I do to read the Flash Memory id:
HAL_SPI_TransmitReceive_IT(SPI_Handlers[channel], bufferIn, bufferOut, bufferSize)�?
where the buffer size is 20 because, the flash id is 20 bytes. Am I right? Or Should I set size as 21 (1 byte for the command and 21 for the read?