AnsweredAssumed Answered

STM32F0 USART1 not work

Question asked by Mancini.Michele on Sep 22, 2012
Latest reply on Sep 23, 2012 by Mancini.Michele
Hi, I have STM32F0 Discovery, I need send a char example 'A' in USART1 that use PA9 to TX.
The configuration are:

    /* Enable GPIO clock */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);   //PA9 ,PA10
  /* Enable USART clock */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
  /* Connect PXx to USARTx_Tx */
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_0);     //PA9 -> TX
  /* Connect PXx to USARTx_Rx */
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_0);    //PA10 -> RX  
  /* Configure USART Tx as alternate function push-pull */
  GPIO_InitStructure.GPIO_Pin = GPIO_PinSource9;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
  /* Configure USART Rx as alternate function push-pull */
  GPIO_InitStructure.GPIO_Pin = GPIO_PinSource10;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
  /* USART configuration */
  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);    
  /* Enable USART */
  USART_Cmd(USART1, ENABLE);

And for trasmit:
      USART_SendData(USART1, (uint8_t) 'A');
      while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
      while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);



But Not work, the arm run correctly but the output PA9 is null trasmit

Outcomes