STM32H735 UART2 HAL_UART_Receive_IT and HAL_UART_Receive puts a first byte in the buffer that is not there.
I am a bit frustrated with the USART2, which is connected to the UART9 TX9-RX2 and TX2-RX9. So with sending from TX9 to RX2 everything is fine but the other way around there is a first byte = 254d inside the receive buffer. huart2 and huart9 are initialized totally equal asynchronous with the default CubeIDE configuration.
huart9.Instance = UART9;
huart9.Init.BaudRate = 115200;
huart9.Init.WordLength = UART_WORDLENGTH_8B;
huart9.Init.StopBits = UART_STOPBITS_1;
huart9.Init.Parity = UART_PARITY_NONE;
huart9.Init.Mode = UART_MODE_TX_RX;
huart9.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart9.Init.OverSampling = UART_OVERSAMPLING_16;
huart9.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart9.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart9.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_TXINVERT_INIT;after Init I do this in the main() routine:
uint8_t cnt = 0u;
uint8_t strU9Sent[6u];
uint8_t strU2Received[6u];
sprintf((char *)strU9Sent, "hello", cnt);
HAL_UART_Receive_IT(&huart2, strU2Received, sizeof(strU2Received));
HAL_UART_Transmit(&huart9 , strU9Sent, sizeof(strU9Sent), 100u);After executing HAL_UART_Receive_IT() one can set a breakpoint at line 6 (code above), there is immediately a character in the strU2Received. Also the blocking HAL_UART_Receive() creates that issue. On the oscilloscope there is no character or something visible.
Why that?
This is reproducible with generated code from CubeIDE 10.0.1.