cancel
Showing results for 
Search instead for 
Did you mean: 

SPI Between two nucleo boards mcu

nesnes
Associate III

 

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.

 

 

 
 
15 REPLIES 15
SofLit
ST Employee

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?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

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  

Need to probe MOSI and MISO lines and check what is going on.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

nesnes_0-1725617475163.png

@SofLit 

 Is there any other way , I don't have an acces to osiloscope right now.

Hello @nesnes 

I tested the project on my side and found that some minor updates are needed. Please find the updated files attached.

 

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

Please find the latest file attached

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar

Hi again @SofLit @Saket_Om 

 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

 

 

 

unnamed.jpg

unnamed.jpg

unnamed.jpg

@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.