AnsweredAssumed Answered

Unable to use USART1_TX PA9 pin because of USB conflict?

Question asked by Reupri.Alban on Aug 22, 2014
Latest reply on Aug 27, 2014 by Reupri.Alban
Hello everybody!

It's not my first experience with USART but this time I have an unsolvable problem :)

I try to use USART1 TX with the pin PA9 but I can't send datas. The pin PA9 always outputs 1.1V and never switch. When I configure the pin as a standard GPIO, I can set it to high and low level (0V and 3.3V) without problems.

I think this is maybe due to the fact I use the USB and the pin PA9 can be used as the VUSB input.

This my code for the USART1 config:
void USART_Config(void)
    RCC_APB1PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);  // USART1 clock
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);   // GPIOA clock
    GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1);      // PIN A9 linked to the USART1
    // Tx GPIO init
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 ;
    GPIO_InitStructure.GPIO_Mode =  GPIO_Mode_AF; // alternate function!
    GPIO_InitStructure.GPIO_OType = GPIO_OType_OD ;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
    GPIO_Init(GPIOA, &GPIO_InitStructure);
    // USART init:
    // Vitesse du MIDI = 31250
    USART_InitStructure.USART_BaudRate = 31250;
    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_Tx;
    USART_Init(USART1, &USART_InitStructure);

Then to send a data I simply use
USART_SendData(USART1, data_out);

Thanks a lot for your help!