Skip to main content
AE104
Associate III
March 29, 2023
Question

Read Continuous Data from An the SPI interface

  • March 29, 2023
  • 2 replies
  • 914 views
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.

This topic has been closed for replies.

2 replies

ST Technical Moderator
April 11, 2023

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 "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL
Karl Yamashita
Principal
April 11, 2023

What ADC are you communicating with?

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source