AnsweredAssumed Answered

STM32F429 USART1 TX sending garbage

Question asked by ferguson.josh on Mar 21, 2014
Latest reply on Mar 21, 2014 by ferguson.josh
Hello,

I am using the STM32F429 board, I have configured the USART1 for TX (PA9) and RX (PA10). For testing purposes i send a buffer of 0x44 values down the USART. I monitor this tranmission on another boards RX pin and print the result to the terminal (for testing purposes). However the USART1 is sending garbage and i am not receiving the 0x44.
I don't think it is a problem with my code because it works perfectly on the STM32F407 when I loop RX and TX pin.

Any suggestions to why I am receiving garbage?

Thanks

void USART1_Configuration(void) 
{
    /* Define the GPIO initial structure */
    GPIO_InitTypeDef  GPIO_InitStructure;
  /* Define the USART initial structure */
    USART_InitTypeDef  USART_InitStructure; 
    /* Define the NVIC initial structure */
    NVIC_InitTypeDef  NVIC_InitStructure;
  
    /* GPIO Peripheral clock enable */
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
    /* USART2 Peripheral clock enable */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
      
    /* Configure PA9 and PA10 */
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
    GPIO_Init(GPIOA, &GPIO_InitStructure);
      
    /* Configure the Tx and Rx pins for USART3 */ 
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1); //TX
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1); //RX
      
    /* USART1 mode configure */ 
    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_Mode = USART_Mode_Tx | USART_Mode_Rx;
    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
      
    /* Initialise and enable the USART1 */ 
    USART_Init(USART1, &USART_InitStructure);
      
    /* enable the interrupt */ 
    USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
      
    /* Enable the USART1 interrupt */
    NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_Init(&NVIC_InitStructure);
      
    USART_Cmd(USART1, ENABLE);
}
  
      
void USART1_IRQHandler(void)
{
    static int rx_index = 0;
    char aTextBuffer[50];
      
  if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) // Received characters modify string
  {
    rx_data[rx_index++] = USART_ReceiveData(USART1);
            if (rx_index >= (sizeof(rx_data) - 1)){
      rx_index = 0;
            fin_flag = 1;
        }
  }
}

Outcomes