Skip to main content
mrkayaalp
Associate II
February 7, 2024
Question

SPI problem in STM32F446 NUCLEO

Hello everyone im currently working on a adc AD7708. I want to read chip from the device but i cant get any valid value. Here is the register sturucture of AD7708:

mrkayaalp_0-1707326670954.png

I wrote a basic code to read the chip id from id register. Here is the code:

 

 

 

 

 

 while (1)
 {
	 HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, 0);
	 status = HAL_SPI_Transmit(&hspi1, txdata, 1, 500);
	 while (hspi1.State != HAL_SPI_STATE_READY)1;

	 status = HAL_SPI_Receive(&hspi1, rxdata, 1, 500);
	 while (hspi1.State != HAL_SPI_STATE_READY);
	 HAL_GPIO_WritePin(SPI1_CS_GPIO_Port, SPI1_CS_Pin, 1);

	 HAL_Delay(10);
 /* USER CODE END WHILE */

 /* USER CODE BEGIN 3 */
 }

 

 

 

 

 

I examined it with the scope and i think there is no problem in MOSI line. But i cant see any signal in MISO line.  Here is my spi settings in stm32cubeide.

mrkayaalp_1-1707327149557.png

I couldn't find the problem. What should i do?

This topic has been closed for replies.

19 replies

AScha.3
Super User
February 7, 2024

Hi,

With full duplex you should use :   HAL_SPI_TransmitReceive( ..) ;

If dont need the received byte, just dont use it, but the spi here always transmit + receive same time.

If you feel a post has answered your question, please click on " Best Answer ".
mrkayaalp
mrkayaalpAuthor
Associate II
February 8, 2024

I already tried it and its not working

AScha.3
Super User
February 8, 2024

So at first set the SPI signals , as this adc needs :

AScha3_0-1707382264134.png

in Cube set : cpol hi + cpha 2 edge .

+ use HAL_SPI_TransmitReceive( ..) ;

+ how to set the command -- i hope you read the manual...

AScha3_1-1707382549482.png

 

If you feel a post has answered your question, please click on " Best Answer ".
TDK
February 7, 2024

If MOSI is working correctly there is no issue on the STM32 side.

Recheck connections to the chip, ensure it's powered and operational and not in any low power or sleep state.

"If you feel a post has answered your question, please click ""Accept as Solution""."
mrkayaalp
mrkayaalpAuthor
Associate II
February 8, 2024

I checked my power supply and its totally fine. Im pretty sure that adc is not  on the low power or sleep state. I think there is no problem with the software side. I will check everything again..