Skip to main content
Explorer II
July 19, 2024
Solved

MAX31856 SPI Communication problem

  • July 19, 2024
  • 1 reply
  • 1697 views

Trying to communicate MAX31856 With STM32F401
STM32CUBEIDE 1.15.1
ADAFRUIT MAX31856 Breakout Board

 

uint8_t data[2];
uint8_t addr_data[2]={0x04,0x00};

 while (1)
 {
 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET);
		 HAL_Delay(10);
	 HAL_SPI_TransmitReceive(&hspi1,&addr_data,&data,2, HAL_MAX_DELAY);
	 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET);
 HAL_Delay(10);
 }

}

 

Trying to Read Register 0x04 (Default Value = 0xC0)

But Getting Random 0x00 or 0x80 Values (Verifying with Logic Analyzer)
Screenshot (18).png

 

    This topic has been closed for replies.
    Best answer by Caan

    Yes, but Right Now I tried to Chang the config to

     

     

     hspi1.Init.CLKPolarity = SPI_POLARITY_LOW; POL is Low
    
     hspi1.Init.CLKPhase = SPI_PHASE_2EDGE; Phase Changed to 2 Edges

     

    And I am Able to get the Data Now.

    Thanks @Andrew Neil 

    1 reply

    Super User
    July 19, 2024

    Correct SPI mode?

    CaanAuthor
    Explorer II
    July 19, 2024

    According to the datasheet the SPI Can be run in SPI 0 Mode (SCK POL 0 or 1)

    Super User
    July 19, 2024

    and is your SPI configured to that?