2019-09-03 10:15 AM
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);
2019-09-03 12:46 PM
Lacking any sort of context here.
What STM32 part, specifically, they make several hundred different ones.
Show the code initializing the USART, and perhaps the MSP code generated for that.
PB6 would need to define the Pin, and use GPIOB rather than GPIOA.
I would front test for TXE rather than back test for TC on the USART status.
Check that the GPIOB and USART1 clocks are enabled.