A stm32 chip configuration master-slave mode test encountered a problem!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-22 08:52 PM
I'm using a SPI1 as a master, SPI2 as a slave, SPI1 provides the clock to SPI2, SPI2 uses the SPI1 clock reference, and when I use __HAL_SPI_ENABLE(&hspi1), the SPI1 clock line pulses, which is fine.but when I call
uint32_t tmp = 0x12345678;
HAL_SPI_Transmit(&hspi2,(uint8_t*)&tmp,4,100);
When using SPI2 to output data, the clock line of SPI1 does not output pulses. I did not turn off SPI1, and SPI2 did not output data. I checked the status register and found no flags. The hardware connection has been connected to SPI1 and SPI2. Excuse me How could something like this happen?
- Labels:
-
SPI
-
STM32CubeMX
-
STM32F4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-22 11:59 PM
If you configure SPI2 as a slave, it cannot transmit on its own but only respond to master requests. So timing is crucial. See https://github.com/STMicroelectronics/STM32CubeF4/ for example projects like SPI_FullDuplex_ComPolling and similar.
hth
KnarfB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-23 06:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-23 10:23 PM
Please use 2 boards to test spi master and slave config. For slave to transmit data, master must generate clock by sending dummy data....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-23 10:44 PM
I see that you are using a single board too.
Anyway, single or two boards, the master should send the clock anyway.
Without any slave connection, the master should be able to generate the clock.
You first solve that problem.
You can try the one on GitHub and generate the clock.
Also, update the firmware to the latest version.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-24 08:38 PM
My idea is similar to yours, but my idea is to use SPI1 to generate a clock signal, and SPI2 also uses this clock signal to send data, not to receive data from SPI1, so SPI1 is used as the master and SPI2 is used as a slave, but I The problem is that when I use the send function of SPI2, SPI1 seems to be broken. SPI1 does not even output the clock signal. Of course, the premise is that the CLK of SPI1 and the slave CLK of SPI2 are connected together, and the CLK of SPI1 can also work normally before the program does not call the sending function of SPI2.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-24 08:40 PM
Thanks for the reply, I need to do some special tests and can't use two boards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-04-25 02:41 AM
Can you post your project/code here?
It is quite difficult to picture what is the problem.