AnsweredAssumed Answered

uart4 interfacing of stm32f4discoveryboard

Question asked by deb.arun on Sep 22, 2014
Latest reply on Sep 23, 2014 by karpavicius.linas
Hi everyone,
I am trying hard to make my uart4 code to working.But I am not getting anything on my hyperterminal.I am using keiluvision4.I have uploadeed th epiece of my code below.Please have a look and suggest me the chanegs required.

 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
 
  /* Enable USART6 clock */
  RCC_APB2PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE);
     
  /* Configure port as pushpull, 50MHz and No pull up & down  */
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
         
  /* Configure PC6 as alternate function  */
  GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_10|GPIO_Pin_11;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
 
  /* Configure PC7 as alternate function  */
  //GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;
 // GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_1;
 // GPIO_Init(GPIOA, &GPIO_InitStructure);
     
  /* Connect PC6 to USART6_Tx*/
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_UART4);
 
  /* Connect PC7 to USART6_Rx*/
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_UART4);
     
  /* USART6 configured as follow:
        - BaudRate = 115200 baud  
        - Word Length = 8 Bits
        - One Stop Bit
        - No parity
        - Hardware flow control disabled (RTS and CTS signals)
        - Receive and transmit enabled
  */
  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 configuration */
  USART_Init(UART4, &USART_InitStructure);
     
  /* Enable USART */
  USART_Cmd(UART4, ENABLE);
     while(USART_GetFlagStatus(UART4, USART_FLAG_TXE) == RESET);
//while( !(UART4->SR & 0x00000040) );
  USART_SendData(UART4, 'a');     

thanks


Outcomes