cancel
Showing results for 
Search instead for 
Did you mean: 

Data sent and receive over UART is different

psati
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions

The Discovery board has an 8 MHz clock

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

6 REPLIES 6

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Bob S
Principal

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.

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.

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);

 }

}

The Discovery board has an 8 MHz clock

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I changed Clock to 8MHz it is working. Thank you so much