When I try sending 4 digits from serial monitor to UART using HAL_UART_Receive()
, the array looks like image shown below.
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:
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.