2022-02-28 08:22 PM
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.
Solved! Go to Solution.
2022-02-28 09:53 PM
Because SPI2 is on AHB1, not AHB2. Try LL_APB1_GRP1_PERIPH_SPI2 See data sheet.
hth
KnarfB
2022-02-28 09:53 PM
Because SPI2 is on AHB1, not AHB2. Try LL_APB1_GRP1_PERIPH_SPI2 See data sheet.
hth
KnarfB
2022-02-28 10:05 PM
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.
2022-02-28 10:15 PM
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
2022-02-28 11:07 PM
Yes, I saw it. So it looks like in that assembly code, each and every IRQ handler is defined.
Thx, @KnarfB
2022-02-28 11:25 PM
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
2022-03-01 02:10 AM
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?
2022-03-01 02:40 AM
2022-03-01 06:53 PM
I read through that link. It seems to me that using SPI4 is not a problem.
I 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?