AnsweredAssumed Answered

STM32F0 USART notworking

Question asked by aruns06 on Nov 7, 2014
Latest reply on Jun 20, 2015 by harshan.manu
Hi,
I am trying to some data from STM32FO devboard(Standard board from ST- MB1304) to PC via usart1. I have created the project in Keil. Data is not transmitting from STM32 to PC. First I thought that code is not running. To check that I have added an led blinking program and then checked. The led starts blinking, but no data via usart. Don't know what went wrong. I think there might be the problem with clock configuration...The code is given below.
int main()
init_usart();
 
   while(1)
    {
        while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET)
        {
            USART_SendData(USART1, 'X');
        }
         
    }
}
 
 
void init_usart()
{
USART_InitTypeDef USART_InitStructure;
  GPIO_InitTypeDef GPIO_InitStructure;
   
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
   
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);
   
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_0);
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_0);
   
  /* Configure USART1 pins:  Rx and Tx ----------------------------*/
  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_9 | GPIO_Pin_10;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
   
  USART_InitStructure.USART_BaudRate = 9600;
  USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  USART_InitStructure.USART_StopBits = USART_StopBits_1;
  USART_InitStructure.USART_Parity = USART_Parity_No;
  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
  USART_Init(USART1, &USART_InitStructure);
   
  USART_Cmd(USART1,ENABLE);
}
.Any suggestions....

Outcomes