AnsweredAssumed Answered

Virtual COM and GPIO_Pin_10 from GPIOA

Question asked by tuset.pere on May 24, 2012
Latest reply on Sep 7, 2012 by muix
Dear all,

We have recently developed a board that includes the STM32F103CB microcontroller (36-pin version) and has a USB connection (mini-USB) to power the device and also to communicate with a computer. We are currently using the source code from the STM32 Virtual COM example but we have adapted it to our current board and needs (only send data). Instead of using the default GPIO port and pin we use GPIO_Pin_10 from GPIOA to trigger when the USB cable is connected or disconnected. The settings are as follows:

#define STM32F10X_USB_DISCONNECT_GPIO           GPIOA
#define STM32F10X_USB_DISCONNECT_CLK            RCC_APB2Periph_GPIOA
#define STM32F10X_USB_DISCONNECT_SPEED          GPIO_Speed_50MHz
#define STM32F10X_USB_DISCONNECT_MODE           GPIO_Mode_Out_OD
#define STM32F10X_USB_DISCONNECT_PIN            GPIO_Pin_10

The Set_System function is as follows:

void Set_System(void) {
    GPIO_InitTypeDef GPIO_InitStructure;
 
    /* Enable USB_DISCONNECT GPIO clock */
    RCC_APB2PeriphClockCmd(STM32F10X_USB_DISCONNECT_CLK, ENABLE);
 
    /* Configure USB pull-up pin */
    GPIO_InitStructure.GPIO_Pin = STM32F10X_USB_DISCONNECT_PIN;
    GPIO_InitStructure.GPIO_Speed = STM32F10X_USB_DISCONNECT_SPEED;
    GPIO_InitStructure.GPIO_Mode = STM32F10X_USB_DISCONNECT_MODE;
    GPIO_Init(STM32F10X_USB_DISCONNECT_GPIO, &GPIO_InitStructure);
}

Finally, the USB_Cable_Function is as follows:

void USB_Cable_Config(FunctionalState NewState) {
    if (NewState != DISABLE) {
        GPIO_ResetBits(STM32F10X_USB_DISCONNECT_GPIO, STM32F10X_USB_DISCONNECT_PIN);
    }
    else {
        GPIO_SetBits(STM32F10X_USB_DISCONNECT_GPIO, STM32F10X_USB_DISCONNECT_PIN);
    }
}

The same code used to work flawlessly in another board using a port from GPIOD (we used a 100-pin microcontroller) and a regular USB connector. As soon as you connected the board through USB the computer detected the device and properly configured the driver. Now the computer does not even detect the device. Using the J-Link debugger we have noticed that the USB_LP_CAN1_RX0_IRQHandler is never called, but I have already spent two days trying to solve it and I do not have any clue.

Therefore, my question is: is there any incompatibility in using GPIO_Pin_10 from GPIOA for that purpose? I have noticed (in the reference manual) that GPIO_Pin_10 is used for USART1 (as an alternate function) and that it is also used for the bootloader, but we are using neither of them. Do you have any ideas on where to look?

Thanks in advance,

Pere

Outcomes