cancel
Showing results for 
Search instead for 
Did you mean: 

unable to drive SPI port using STMCube generated code

bnp979
Associate III
Posted on December 10, 2014 at 23:38

Hi,

I am trying a simpleexperiment using my STM L1 Discovery board. I have created a project using the STMCubeMX GUI that has the SPI port enabled as Master. The clocks have been configured correctly and I have a GPIO port enabled as well.

All I am trying to do is to repeatedly send data on the SPI port (SPI2) using the ''HAL_SPI_TransmitReceive'' function. When doing so I see no activity on the SPI CLOCK or MOSI pins of the board.

The necessary SPI initialization function is indeed present (MX_SPI2_Init()).

I can also toggle my GPIO pin successfully which shows that the system clock has been configured.

I also removed the LCD from the board as indicated in the board datasheet to make sure that has been taken out of the picture.

Any idea what might be going on here? I'm thinking it is some gotcha that I am running into.

If anybody can point to sample SPI code for the L152RC part that would be helpful.

I am most concerned about the port assignment. My understanding is that the cube routines should do this automatically (within the HAL_SPI_MspInit function), but I'd like to try a known example.

Thanks,

Ben
2 REPLIES 2
Amel NASRI
ST Employee
Posted on December 11, 2014 at 14:56

You should find SPI examples in the

http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/LN1897/PF260821

package.

Check them to know what is missed in your configuration using CubeMX.

-Mayla-

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.

dis
Associate
Posted on February 05, 2015 at 19:54

I had a similar issue and after some frustration I got it to work.  Here's what I did.

Go into Cube and in the configuration tab click on the SPI peripheral.  Change the Prescaler for Baud Rate to 256.  Then go to the GPIO setting tab and click on each of the pins and change their Maximum Output Speed to Fast.

After that I finally saw a clock on the pin.