Skip to main content
Caan
Associate III
July 19, 2024
Solved

MAX31856 SPI Communication problem

  • July 19, 2024
  • 5 replies
  • 1759 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 

5 replies

Andrew Neil
Super User
July 19, 2024

Correct SPI mode?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Caan
CaanAuthor
Associate III
July 19, 2024

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

Andrew Neil
Super User
July 19, 2024

and is your SPI configured to that?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.