2024-07-19 04:58 AM
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)
Solved! Go to Solution.
2024-07-19 06:27 AM
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
2024-07-19 05:52 AM
Correct SPI mode?
2024-07-19 05:56 AM
According to the datasheet the SPI Can be run in SPI 0 Mode (SCK POL 0 or 1)
2024-07-19 05:59 AM
and is your SPI configured to that?
2024-07-19 06:07 AM
Seems you have to set:
2024-07-19 06:27 AM
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