Skip to main content
taraben
Associate III
November 22, 2018
Question

Failure on STM32L4 SPI receive

  • November 22, 2018
  • 2 replies
  • 731 views

Hello All,

I have an STM32L486 and use the SPI3 to connect a SPI flash device.

The code uses CubeMX L4 1.13 HAL SPI and seems to work.

But after reflash or reboot the SPI returns only 00h values.

After an power on reboot it looks all fine.

I compared in that cases the CR1,CR2,SR registers also AF assignment. And all those look fine.

I saw some items in the forum but do not know if that is related to my case.

Ususally I work with STM32F437 that has SPI with no FIFO.

The L468 device has FIFO.

Any pointers where to look?

regards. Adib.

--

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
November 22, 2018

External SPI Flash devices frequently lack an async reset pin, therefore can come up in an indeterminate state, especially if you don't have pull-ups to hold states of things like CS, and CLK pins.

Your startup code should try to read the chip id registers, and be able to retry. Check if any reset methods are described in the part's data sheet.

Suggest you use a scope or analyzer to see what's actually happening at the pins, and how the Flash device is responding.

Avoid placing a debug view over the SPI Peripheral registers, and instead add code to print diagnostic/telemetry about what it sees and what is happening from within the code.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
taraben
tarabenAuthor
Associate III
November 22, 2018

Hello Clive, Thanks for fast response.

Actually I do try to read the ChipID. Although I do not repeat.

I always send a dummy byte before communicate to let the SPI settle clock polarity.

I print the register values using SEGGER RTT using JLINK before and after the HAL functions.

I connected wires to the pins to check with saleae and will report tomorrow.

Regards, Adib.

--

taraben
tarabenAuthor
Associate III
November 23, 2018

I confirm that the FLASH works so far.

But the MISO line is somehow driven low.

As I use SPI3 on PC10/11/12 I checked the AF values on GPIOC and they are on 666 for those. That is correct. Mode is on 222, also correct.

I tried to change the GPIO to Input but that low drive remains.

(I do have resistors in between CPU and flash)

I checked the chip-errata but there is nothing related GPIOC or SPI.

Any idea?

Regards, Adib.

taraben
tarabenAuthor
Associate III
November 23, 2018

And always if you think you found a hardware problem, it is a software problem ;)

I use wrong commands on that flash and that cause the chip to malfunction ....

Adib.