I am working on usart and I need to know the configuration for the code. Can someone check this and let me know if this config is correct or not. 9600 baud rate with 1 stop bit and no parity. I am working on usart1 which is connected to pb6 ( TX )
void sendchar(char c)
{
USART1->TDR = c;
while(!(USART1->ISR & USART_ISR_TC));
}
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USART1_UART_Init();
while (1)
{
sendchar('a');
}
}
// gpio config for pb6 (tx)
/*Transmission Pin */
GPIO_InitStruct.Pin = usart_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF0_USART1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);