cancel
Showing results for 
Search instead for 
Did you mean: 

from stm32f4 to stm32l4

Xian Barbosa
Associate II
Posted on March 27, 2017 at 23:36

Hello! I have a working spi driver code(a wrapper for SPI HAL driver) for STM32F407 and tried using the same spi driver for STM32L476 but it is not working. I tried slowing down the clock for spi interface and different clock configurations but no success. Any ideas what else I should look at? My spi_read and spi_write takes the same arguments as hal_spi_receive and hal_spi_transmit.

Thanks.

8 REPLIES 8
S.Ma
Principal
Posted on March 28, 2017 at 09:44

The SPI on L4 has been improved for higher throughput. It might be useful to look at a L4 Cube example to find out if some of the transmit/receive functions have variants depending on the 8/16 read/write to the HW SPI.DR (FIFO)

Amel NASRI
ST Employee
Posted on March 28, 2017 at 10:58

Hi

cianak

‌,

Have a look to

http://www.st.com/content/ccc/resource/technical/document/application_note/group0/02/46/be/cf/31/75/4e/de/DM00263732/files/DM002637pdf/jcr:content/translations/en.DM002637pdf

(Migrating from STM32F405/415 line and STM32F407/417 line toSTM32L4 Series microcontrollers) and mainly 'Table SPI differences between STM32F405/415 line, STM32F407/417 lineand STM32L4 Series'.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Xian Barbosa
Associate II
Posted on March 28, 2017 at 16:50

Thank you for your answers. I've already looked at CubeMx examples and the AN4821 document. I made sure that the SPI configuration uses the 8bit read and write, but still doesn't work.

Posted on March 28, 2017 at 17:23

As already suggested by

Centauris.Alpha

‌, have a look to SPI examples available in the Cube L4 packages, try to run one of them on your L4 device, then compare your code with the one of the example to know what is going wrong exactly.

Depending on selected board, you will find the SPI examples under a path similar toSTM32Cube_FW_L4_V1.7.0\Projects\STM32L432KC-Nucleo\Examples\SPI.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Posted on March 28, 2017 at 18:10

Hi Amel,

That's what I looked at. I compared the SPI Project Examples for STM32Cube_FW_L4_V1.7.0 and STM32Cube_FW_F4_V1.15 are exactly the same. Do I need to worry about FIFO for rx and tx on STM32L4? 

Thanks.

damh
Associate II
Posted on April 28, 2017 at 11:06

We have the same problem. HAL-Driver doesn't work (loses bytes, if more then about 10 bytes are transmitted)

Polling and DMA are affected.

Our solution/workaround: our old assembler code from F103 works fine (only register addresses changed). The code have to block all interrupts, otherwise the bytes are lost, too.

Perhaps, there is a hardware problem. (we are using STM32L471 E and G)

Posted on April 28, 2017 at 13:31

SPI with Fifo has a bit different behaviour than SPI without Fifo. With FIFO, if SPI is in 8 bit mode, a physical read/write of 16 bit DR register will queue 2x8 bits while previously the MSB was discarded.

jin lu
Associate II
Posted on May 30, 2018 at 20:47

Hi, an update on this issue?  Do you have a resolution?   Thanks.