cancel
Showing results for 
Search instead for 
Did you mean: 

F411 SPI2 Not Defined

HDaji.1
Senior

I am using example code SPI_TwoBoards_FullDuplex_DMA, and want to change SPI1 to SPI2.

LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SPI2);

However, in the above line, compiler complains LL_APB2_GRP1_PERIPH_SPI2 not defined.

I wonder why.

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

Because SPI2 is on AHB1, not AHB2. Try LL_APB1_GRP1_PERIPH_SPI2 See data sheet.

hth

KnarfB

View solution in original post

8 REPLIES 8
KnarfB
Principal III

Because SPI2 is on AHB1, not AHB2. Try LL_APB1_GRP1_PERIPH_SPI2 See data sheet.

hth

KnarfB

I have another question:

For the SPI Tx/Rx callback functions, they are called in IRQ handler like DMA2_Stream0_IRQHandler. But I cannot find in the project where DMA2_Stream0_IRQHandler is registered.

The names of the IQR Handlers are defined in the startup code, interrupt vector table, assembly code. Something like startup_stm32f411retx.s. They are pre-defined with a dummy implementation "Default_Handler", but you can override them by implementing a function with exactly that name in your own code.

hth

KnarfB

Yes, I saw it. So it looks like in that assembly code, each and every IRQ handler is defined.

Thx, @KnarfB​ 

Correct. Thats for your convenience. When creating bare bone projects, you don't have to define them all. But each handler must be at a well-known address (offset) such that the CPU-core can fetch it. That's why having all the dummies makes sense.

hth

KnarfB

Hi @KnarfB​ ,

Sorry to trouble you again.

I changed SPI1 to SPI4.

I used PA13, 14, and 15 as clock, MISO, MOSI.

The DMA2 stream0 and stream1 as Rx and Tx.

When I run the code, I cannot detect any signals from those 3 pins.

What went wrong?

I read through that link. It seems to me that using SPI4 is not a problem.

0693W00000Kb3nyQAB.pngI think the problem is PA13, 14, and 15 are not SPI4's default pins. I found SPI4 default pin info in its data sheet: PB13, PA1, PA11.

Can I assign different pins?