Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

HAL_UART_receive function is not writing the data to rxData[] properly

$
0
0

When I try sending 4 digits from serial monitor to UART using HAL_UART_Receive() , the array looks like image shown below.

enter image description here

enter image description here

Now that 1234 is stored in an array, if I re-execute the code, to write to the same array, say 1465 , the array now looks totally different something like this:

enter image description here

Here is the code:

uint8_t rxData[10];

while (1)  {    /* USER CODE END WHILE */          HAL_UART_Receive(&huart2, rxData, 4, HAL_MAX_DELAY);      HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, SET);      HAL_Delay(500);      HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, RESET);      HAL_UART_Transmit(&huart2, rxData, 4,1000);    /* USER CODE BEGIN 3 */  }  /* USER CODE END 3 */}

I have tried to reset and start again, yet it still shows the same.


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>