cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103 Usart problem

akramin
Associate
Posted on December 20, 2010 at 04:30

STM32F103 Usart problem

1 REPLY 1
Posted on May 17, 2011 at 14:18

You need to ensure that the AFIO is clocked for remapping to work. If you are using a different crystal you'll need to ensure the system is clocking at the speed the library code expects it to.

Try cleaning up the GPIO configuration

void GPIO1_Configuration(void)

{

  GPIO_InitTypeDef GPIO_InitStructure;

  /* Enable AFIO clock */

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

    /* Enable the USART2 Pins Software Remapping */

      GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);

      /* Configure USART2 Tx (PA.02) as alternate function push-pull */

      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;

      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

      GPIO_Init(GPIOA, &GPIO_InitStructure);               

      /* Configure USART2 Rx (PA.3) as input floating */

      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

      GPIO_Init(GPIOA, &GPIO_InitStructure);

  }

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..