AnsweredAssumed Answered

SMT32VL-Discovery UART

Question asked by bucher.ron on Dec 13, 2011
Latest reply on Jan 2, 2012 by nava.hernandez
Hi all
I try to success a connection between PC and SMT32VL-Discovery Board via USART.
The Data receive but are not correct. I tryed everything, but the data i receive on PC are still 
wrong.
Has anyone any idea?
01.GPIO_InitTypeDef GPIO_InitStructure;
02.USART_InitTypeDef USART_InitStructure;
03.USART_ClockInitTypeDef USART_ClockInitStructure;
04.//enable bus clocks
05.SystemInit();
06.RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA | RCC_APB2Periph_AFIO, ENABLE);
07.//Set USART1 Tx (PA.09) as AF push-pull
08.GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
09.GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
10.GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
11.GPIO_Init(GPIOA, &GPIO_InitStructure);
12.//Set USART1 Rx (PA.10) as input floating
13.GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
14.GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
15.GPIO_Init(GPIOA, &GPIO_InitStructure);
16.USART_ClockStructInit(&USART_ClockInitStructure);
17.USART_ClockInit(USART1, &USART_ClockInitStructure);
18.USART_InitStructure.USART_BaudRate = 9600;
19.USART_InitStructure.USART_WordLength = USART_WordLength_8b;
20.USART_InitStructure.USART_StopBits = USART_StopBits_1;
21.USART_InitStructure.USART_Parity = USART_Parity_No;
22.USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
23.USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
24.//Write USART1 parameters
25.USART_Init(USART1, &USART_InitStructure);
26.//Enable USART1
27.uint8_t ch = 0x53;
28.USART_Cmd(USART1, ENABLE);
29.uint16_t test = 0x0000;
30.for(i = 0; i < 100; i++)
31.{
32.    USART_SendData(USART1, ch);
33.    while(USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET)
34.    {
35.    }
36.}

 

Outcomes