cancel
Showing results for 
Search instead for 
Did you mean: 

spi1 and spi2 in same project not working on spi2. spi1 works

Weightwatcherphil
Associate II

 i have a stm32u5a5 board but I needed a SPI full duplex Master example with DMA so i used the one for stm32u575.

full duplex Master DMA

it runs fine on my u5a5 board.

i added a SPI 2 channel and i cannot get it to work.  i only want to run them one at a time now.

i think i have the SPI 2 configured properly.

can you please give me some advice.

i have attached my .ioc file

I am using STM32cubeMX  6.12.1

 

stm32 cubeIDE 1.16.1

 

 

firmware 1.6.0

one question is the u575 different between u5a5 on how it runs SPI 2

thanks

phil

 

7 REPLIES 7

@Weightwatcherphil wrote:

i think i have the SPI 2 configured properly.


So if you have just SPI2 - without SPI1 - does that work?

You'll need to show your, tell what board you have, etc:

https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228

 

What, exactly, does "not working" mean here?

  • code crashes?
  • anything seen on the SPI lines?
  • etc?

i running the code on a nucleo-u5a5 board.

i pulled the SPI FULL DUPLEX MASTER DMA example. (i could not find the example for u5a5)

generated code with STM32cubeMX 6.12.1

used u5 firmware 1.6.0

 

i compiled the example using STM32cube IDE 1.16.1 and ran it with SPI1 and it ran on the u5a5 board.

then  i used STM32cubeMX 6.12.1 to remove spi1 and add spi2.

and generated new code.

i used STM32cubeIDE 1.16.1 to compile and i had to change some spi instances  to spi2 instance in a few places.

i kept the same DMA channels

this code did not run.

iin particular when i transmitted the spi data i never got a COMPLETE back.

thank you so much for your quick response.

i have attached my .ioc file 

since i am using the example code i will not repeat it here.

phil

 

to be clear when i use MXcube to generate the code it is showing U575 as the board..

it am just thinking for SPI the u5a5 and u575 seem the same.

and for SPi1 it worked.


@Weightwatcherphil wrote:

when i transmitted the spi data i never got a COMPLETE back.


But was anything actually transmitted on the SPI wires?

Was the clock generated?

I expected SPI2_SCLK on pin PB10 which on my nucleo-u5a5zj board is on CN12 pin 25.

there are no clocks.  

I will recap my problem.

 

i started out trying to find a SPI FULL DUPLEX MASTER DMA example.for nucleo-u5a5 board but could not find one.

instead i did find one on a nucleo-u575 board and i pulled it and compiled it and it ran.

on my nucleo-u5a5 board.  I think the u5a5 and u575 have identical resisters for SP1 but i am not sure.

I see clocks on the SPI1_sclk pin.(PA5  CN12 pin 11) when i run the original example.

so I asked stm32cubeMX (6.12.1) to remove SPI 1 and add SPI2..

I configured SPI2 with DMA just like SPI1 and i generated new code

I changed the main.c file in  code to use hspi2 in a few places 

i also tried taking the example and removing SPI 1 and then putting it back.

i had to carefully the SPI parameters but i was able to get it to run again.

since i have no SPI2 clocks i think the clocks must be configure wrong but the MX tool shows 160mhz going to SPI2.

i am attaching my complete project with spi1 which does work and the one where i replaced SPI1 with SPI2.

i run them both on a nucleo-u5a5ZJ board.

l put the u5a5 startup file in both projects.

if you put a breakpoint at line 163 in main.c in the project with SPI1  it will stop there when you run the program in debug mode (after you push the blue button on the board). you do not need any chips on the spi bus.

if you run the project with SPI 2 it will not hit the breakpoint and you will not see any clocks on pin PB10 CN12 pin 25.

i have attached both projects.

you will need a nucleo-u5a5ZJ board to test.

and if by some chance the SPI 2 registers on u575 are not the same as the ones on U5a5 then my idea will never work.  if you can confirm the SPI2 registers on both boards that would be helpful and i will continue to look for my problem.  i feel it is in the clocks and they are what i understand the least.

thank you so much for all your timely support.

phil

and i used 

 

 


@Weightwatcherphil wrote:

there are no clocks.  


Right - so the transmission did not even start.

If the transmission did not start, then clearly you will never get a COMPLETE signal.

Have you used the debugger to confirm that your code does actually reach the point where the transmission should start?

 

Weightwatcherphil
Associate II

Yes the code reaches the Hal transmitandreceive statement and gets all the way to the while loop. The zip files contain the entire project so you can try it for yourself .