UART debugging
I setup my custom board with STM32F401RE. I am using the HSI a the moment with configuration shown in the image below. All I am doing is printing some lines using this function on the UART2:
#ifdef __GNUC__
/* With GCC, small printf (option LD Linker->Libraries->Small printf
set to 'Yes') calls __io_putchar() */
int __io_putchar(int ch)
#else
int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
{
HAL_UART_Transmit(&huart2, (uint8_t *)&ch, 1, HAL_MAX_DELAY);
return ch;
}But on my serial terminal, I cannot read the right characters. I have tried with different baud rates and that did not make any difference. I am using a logic analyzer to read the data from the Tx pin and it always reads the correct characters. These are the bit timings on the UART pin:
104.160us for 9600
51.480us for 19200
8.60us for 115200
When I calculate the exact baud rates for these timings, they are a bit off to the exact value but AFAIK, it is always the case on the UART. What am I missing here? How can I print the correct characters on my serial terminal? I have tried putty and H-term so far and both always printed the garbage characters.
