AnsweredAssumed Answered

stm32f051 usart1

Question asked by tomtom on Feb 25, 2013
Latest reply on Feb 26, 2013 by tomtom
Hi, I'm switching from a stm32f100 to the stm32f051, most of the code is working already. but the usart1 does not work. The output doesn't change when I am trying to send something.

Here are some snippets of my code:
1.RCC_USARTCLKConfig(RCC_USART1CLK_PCLK);
2.RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB);
3.RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_USART1, ENABLE);

01.  GPIO_InitTypeDef GPIO_InitStructure;
02.  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
03.  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
04.  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
05. 
06. 
07./* Configure USART1 RX (PA.10) as input floating */
08.  GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_0);
09.  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
10.  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
11.  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
12.  GPIO_Init(GPIOA, &GPIO_InitStructure);
13. 
14./* Configure USART1 TX (PA.9) as alternate function push-pull */
15.  GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_0);
16.  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
17.  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
18.  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
19.  GPIO_Init(GPIOA, &GPIO_InitStructure);

01.USART_InitTypeDef USART_InitStructure;
02. 
03.USART_DeInit(USART1);
04. 
05./* USARTx configured as follow:
06.    - BaudRate = 115200 baud
07.    - Word Length = 8 Bits
08.    - One Stop Bit
09.    - No parity
10.    - Hardware flow control disabled (RTS and CTS signals)
11.    - Receive and transmit enabled
12.*/
13.USART_InitStructure.USART_BaudRate = 115200;
14.USART_InitStructure.USART_WordLength = USART_WordLength_8b;
15.USART_InitStructure.USART_StopBits = USART_StopBits_1;
16.USART_InitStructure.USART_Parity = USART_Parity_No;
17.USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
18.USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
19. 
20./* Configure USART1 */
21.USART_Init(USART1, &USART_InitStructure);
22. 
23./* Enable the USART1 */
24.USART_Cmd(USART1, ENABLE);
25. 
26./* Enable USART1 Receive interrupt */
27.USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);

Can anyone tell me, if there is a problem with the initalization?

Thank you for every help.

Outcomes