HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)
I am a new member, I am learning about UART data transmission of MCU STM32F411RE on a nucleon board. I have read and understood the function HAL_UART_Transmit. However, in this function, there is a part I don't understand. I don't understand the meaning of the program below:
if (huart->Init.WordLength == UART_WORDLENGTH_9B)
{
if (UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_TXE, RESET, tickstart, Timeout) != HAL_OK)
{
return HAL_TIMEOUT;
}
tmp = (uint16_t *) pData;
huart->Instance->DR = (*tmp & (uint16_t)0x01FF);
if (huart->Init.Parity == UART_PARITY_NONE)
{
pData += 2U;
}
else
{
pData += 1U;
}
}
In the 9-Bit frame mode, why after each assignment of data from the pData pointer to the DR register:
- pData += 2U if Parity = PARITY_NONE
- pData += 1U if Parity != PARITY_NONE
As I understand it, after: tmp = (uint16_t *) pData;
huart->Instance->DR = (*tmp & (uint16_t)0x01FF);
Then the pointer will be incremented by 1 to assign the next memory area to DR. So why is there a case where the pData pointer grows to 2U. If so, is it possible that the transmitted data will be wrong?
Hope everyone can answer. Thank you.
