cancel
Showing results for 
Search instead for 
Did you mean: 

Read Continuous Data from An the SPI interface

AE104
Senior
int main (){
 
uint16_t txConvertData[2]={0};
uint16_t rxConvertData[2]={0};
 
 const uint16_t ConvertCommandMask = 0b0000000000000000;
 
while(1){
for (int j = 0; j < 2; j++) {
	  		  // Send read command
	  		HAL_GPIO_WritePin(IN_SPI2_CS_GPIO_Port, IN_SPI2_CS_Pin, GPIO_PIN_RESET);
	  		hal_status = HAL_SPI_TransmitReceive(&hspi2, (uint8_t*) &txConvertData[j], (uint8_t*) &rxConvertData[j], 1, 100);
	  		HAL_GPIO_WritePin(IN_SPI2_CS_GPIO_Port, IN_SPI2_CS_Pin, GPIO_PIN_SET);
	  		HAL_Delay(100);
	  		  if (hal_status != HAL_OK) {
	  			  printf("HAL SPI TransmitReceive error: %d\r\n", (int) hal_status);
	  		  }
 
		  }
}

Hello,

On a custom designed PCB, there is STM32F407 processor and its SPI interface get a data from an external ADC. My aim is that getting the converted signal from the ADC continuously. When I started to debug session, I got the conversion value just one at time. Do you have a suggestion to solve the problem?

In addition, I tried to plot SW trace plotting in the debug session but I didn't get nothing.

2 REPLIES 2
FBL
ST Employee

Hello @AE104​,

Try to read through DMA to be able to continuously receive data from the ADC.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.


I'm out of offce with limited access to my emails.
Happy New Year!
Karl Yamashita
Lead III

What ADC are you communicating with?

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.