How to transmit UART data on STM32 discovery board?
Hi forum,
I'm developing on the stm32f3disovery board with STM32F3-Discovery_FW_V1.1.0 running in IAR Embedded Workbench. I've been able to get the basic demo compiled and running, but I can't seem to get UART data transmission to work. There are no error messages, just no output on the serial terminal when I transmit data. I've made sure to match the serial terminal and UART peripheral settings. Below is the UART initialization and runtime code that I have:
//Set up UART peripheral
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource4, GPIO_AF_7);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource5, GPIO_AF_7);
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStruct);
USART_InitTypeDef USART1_Struct;
USART1_Struct.USART_BaudRate = 38400;
USART1_Struct.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART1_Struct.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART1_Struct.USART_Parity = USART_Parity_No;
USART1_Struct.USART_StopBits = USART_StopBits_1;
USART1_Struct.USART_WordLength = USART_WordLength_8b;
USART_Init(USART1, &USART1_Struct);
USART_Cmd(USART1, ENABLE); //Transmit heading value over UART for display
while(USART_GetFlagStatus(USART1, USART_FLAG_BUSY)) {};
USART_SendData(USART1, 15);Thanks!