cancel
Showing results for 
Search instead for 
Did you mean: 

MAX31856 SPI Communication problem

Caan
Associate III

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

 

1 ACCEPTED SOLUTION

Accepted Solutions

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 

View solution in original post

5 REPLIES 5
Andrew Neil
Evangelist III

Correct SPI mode?

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

and is your SPI configured to that?

Seems you have to set:

AScha3_0-1721394426857.png

 

If you feel a post has answered your question, please click "Accept as Solution".

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