AnsweredAssumed Answered

help with usart peripheral.

Question asked by KernelSanders on Jun 25, 2013
Latest reply on Jun 25, 2013 by KernelSanders
Hello,
I am having some difficulties getting my uart code to work. Can someone please tell me what I am missing? I must have spent too much time looking at it and am missing something very obvious because I have written uart code before. The strange thing is it works in one project but not the other. Is there something else that could be causing a problem that may not be setup somewhere?
 Here is my code...

    GPIO_InitTypeDef GPIO_InitStructure;
   
   RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
   
   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
     
   GPIO_PinRemapConfig(GPIO_PartialRemap_USART3, ENABLE); 
     
 // Configure USART3 Tx (PC.10)as alternate function push-pull   
   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;   
   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;   
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;   
   GPIO_Init(GPIOC, &GPIO_InitStructure);    
     
   /* Configure USART3 Rx PC.11 as input floating */   
   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;   
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;   
   GPIO_Init(GPIOC, &GPIO_InitStructure); 
     
   USART_InitTypeDef USART_InitStructure;
   RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); 
     
 
  /* USART 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 = 115200;
  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(USART3, &USART_InitStructure);
   
  USART_Cmd(USART3, ENABLE);

Outcomes