2024-09-06 12:49 AM - edited 2024-09-06 01:08 AM
I am trying to establish communication between two Nucleo boards (STM32G431RB as master and Nucleo F446RE as slave). I used the example codes from the STM32 GitHub page (NUCLEO-G431RB/Examples/SPI/SPI_FullDuplex_ComPolling_Master and STM32F411RE-Nucleo/Examples_MIX/SPI/SPI_FullDuplex_ComPolling). I made some changes to the slave code, including GPIO settings, but the communication still doesn't work. I chose NSS as [ hspi1.Init.NSS = SPI_NSS_SOFT; ]. The codes also include LED configurations as mentioned in the README files, which indicate an error based on the LED status.I know I have an error acording to led 2 but I don't know the problem.
LED2 toggles slowly when there is a timeout or an error in transmission/reception process.
2024-09-06 01:26 AM - edited 2024-09-06 01:27 AM
Hello,
Here you are using different MCU part numbers. Did you use the same example of STM32G432 for STM32F446RE? if yes, did you adapt the SystemClock frequency as well as the SPI bitrate?
2024-09-06 03:09 AM
Hello @SofLit
No I used different examples for the boards g4 master example for g4 and f4 example for f446re. Adjust the frequency and datasize acordingly at 100 Mhz(HCLK) and 8bit
2024-09-06 03:11 AM
Need to probe MOSI and MISO lines and check what is going on.
2024-09-06 03:13 AM
2024-09-06 03:19 AM - edited 2024-09-06 03:25 AM
Is there any other way , I don't have an acces to osiloscope right now.
2024-09-09 04:08 AM
Hello @nesnes
I tested the project on my side and found that some minor updates are needed. Please find the updated files attached.
2024-09-09 04:10 AM
2024-09-09 04:19 AM - edited 2024-09-09 06:50 AM
I tried different code for my spi communications but this time my master transmits the data but slave does not receive it. I tested with debugger breakpoint , there is no problem on the masters side , but slave jumps this if statement due to data not being received (HAL_TIMEOUT) . I have added the master and slave codes
while (1)
{
/* USER CODE END WHILE */
/* SPI veri alımı (slave) */
if (HAL_SPI_Receive(&hspi3, RX_Buffer, sizeof(RX_Buffer), 5000) == HAL_OK)
{
// Veri başarıyla alındıysa LED2'yi tam yak
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET); // LED2'yi yak
/* HAL_Delay(5000); // LED2'yi 500 ms boyunca yak */
/* HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET); // LED2'yi kapat */
}
HAL_Delay(100); // 100 ms bekle
2024-09-09 06:49 AM
@Saket_Om I recived HardFault error when I debug on the master side with the updated code . In the replies there is an other simpler code example that I'm trying right now , could you help me with those ? I decided to try half_duplex insteed of fulll_duplex first .
Program received signal SIGTRAP, Trace/breakpoint trap.
HardFault_Handler () at C:/git/STM32CubeG4/Projects/NUCLEO-G474RE/Examples/SPI/SPI_FullDuplex_ComPolling_Master/Src/stm32g4xx_it.c:86
86 {
warning: Could not fetch required XPSR content. Further unwinding is impossible.
Program received signal SIGINT, Interrupt.
0x080005b0 in HardFault_Handler () at C:/git/STM32CubeG4/Projects/NUCLEO-G474RE/Examples/SPI/SPI_FullDuplex_ComPolling_Master/Src/stm32g4xx_it.c:90
90 while (1)
warning: Could not fetch required XPSR content. Further unwinding is impossible.