2018-11-02 09:10 AM
Hi,
I am working on USART3 in STM32F407VG Discovery board using stm pheripheral libraries. I am sending a character 'a' but in serial port i am getting data as 3. Please check my main function and kindly help.
Solved! Go to Solution.
2018-11-02 06:29 PM
The Discovery board has an 8 MHz clock
2018-11-02 11:38 AM
It uses CMOS voltage levels, not RS232, you can't just plug it into a PC
The other possibility is your board settings are wrong, if HSE_VALUE is incorrect, baud rates will be set incorrectly.
2018-11-02 11:39 AM
Please post your code in-line instead of adding an attachment. If you code is HUGE, cut out any non-essential code to a bare minimum that exhibits the issue. Use the "code snippet" button to make it more readable. Downloading files from forums can be problematic/not allowed for some of us.
2018-11-02 05:46 PM
I am using TTL(5V) to USB converter to check the data in serial port. and my HSE_VALUE is #[define HSE_VALUE ((uint32_t)25000000.] . I am using Baudrate as 9600 in code as well as in PC serial port.
2018-11-02 05:53 PM
Hi Bob S,
These are my functions. Connections and Baud values are also collect.
void usart3_fun()
{
USART_InitTypeDef my_usart_init;
GPIO_InitTypeDef my_gpio_init;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
my_gpio_init.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
my_gpio_init.GPIO_Mode = GPIO_Mode_AF;
my_gpio_init.GPIO_OType = GPIO_OType_PP;
my_gpio_init.GPIO_PuPd = GPIO_PuPd_UP;
my_gpio_init.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_USART3);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_USART3);
my_usart_init.USART_BaudRate = 9600;
my_usart_init.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
my_usart_init.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
my_usart_init.USART_Parity = USART_Parity_No;
my_usart_init.USART_StopBits = USART_StopBits_1;
my_usart_init.USART_WordLength = USART_WordLength_8b;
GPIO_Init(GPIOB, &my_gpio_init);
USART_Init(USART3, &my_usart_init);
USART_Cmd(USART3, ENABLE);
}
int main(void)
{
RCC_GetClocksFreq(&RCC_Clocks);
SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
uint16_t ch = 'a';
usart3_fun();
while (1)
{
USART_SendData(USART3,ch);
Delay(1000);
}
}
2018-11-02 06:29 PM
The Discovery board has an 8 MHz clock
2018-11-03 01:10 AM
I changed Clock to 8MHz it is working. Thank you so much