cancel
Showing results for 
Search instead for 
Did you mean: 

Struggling to get USB CDC device working with NUCLEO-F411RE directly connected to computer, but not with STM32F411E-DISCO

evenlund
Associate III

I have been struggling to get USB CDC device to work for the Nucleo without any additional USB peripherals. USB CDC works perfectly fine when I use the DISCO-board connected through the USB-micro, with the same MCU as the NUCLEO.


_legacyfs_online_stmicro_images_0693W00000birxqQAA.png 

I have connected a cut USB A cable and using code like shown in this blog post (just other pin locations for the F411 compared to F042): https://shawnhymel.com/1795/getting-started-with-stm32-nucleo-usb-virtual-com-port/


_legacyfs_online_stmicro_images_0693W00000biscUQAQ.png 

I have tested removing the ground and shield connections as well as the 5V from the Nucleo, one at a time. When I connect the USB-cable to my computer I don't see any new devices in windows device manager. Why is the connection not recognized? Do I need additional resistors on the D+ and D- lines, when I want to set it up as device?

In a desperate attempt I have also tried adding this renumeration code, but the device is still not detected:

  /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
 
    /*
     * Force host to re-enumerate device
     */
    GPIO_InitTypeDef GPIO_InitStruct = { 0 };              // All zeroed out
    GPIO_InitStruct.Pin = GPIO_PIN_12;                     // Hardcoding this - PA12 is D+
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;            // Push-pull mode
    GPIO_InitStruct.Pull = GPIO_PULLDOWN;                  // Resetting so pull low
    GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;               // Really shouldn't matter in this case
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);                // Initialize with above settings
    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET); // Yank low
    HAL_Delay(50);                                         // Enough time for host to disconnect device
    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_SET);   // Back high - so host will enumerate
    HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12);                   // Deinitialize the pin
 
  /* USER CODE END USB_DEVICE_Init_PreTreatment */

https://stm32world.com/wiki/STM32_USB_Device_Renumeration

1 ACCEPTED SOLUTION

Accepted Solutions
evenlund
Associate III

I found out how to make USB work with the NUCLEO-F411RE:

You need to couple the D+ (PA12) via a 1.5 kohm resistor to 3.3 V:


_legacyfs_online_stmicro_images_0693W00000bl3U1QAI.pngI now supply 5V and GND from the computer (red and black wire) and the resistor is connected from 3.3V to the pin on the other side of the board of where the green D+ wire is connected. You can leave the shielding disconncted or connect to GND.

By connecting the USB-cable this way I am able to power the board directly without any additional USB cable connected to the USB micro connector. This is not possible when connecting the red wire to E5V! Care must be taken though, as I don't think is a good thing connecting both the USB micro cable and the DIY cable simultaneously. The workflow would be to flash the board with the micro-connector connected and then unplug and plug in the DIY USB connector to the computer when powering and running the application.

View solution in original post

1 REPLY 1
evenlund
Associate III

I found out how to make USB work with the NUCLEO-F411RE:

You need to couple the D+ (PA12) via a 1.5 kohm resistor to 3.3 V:


_legacyfs_online_stmicro_images_0693W00000bl3U1QAI.pngI now supply 5V and GND from the computer (red and black wire) and the resistor is connected from 3.3V to the pin on the other side of the board of where the green D+ wire is connected. You can leave the shielding disconncted or connect to GND.

By connecting the USB-cable this way I am able to power the board directly without any additional USB cable connected to the USB micro connector. This is not possible when connecting the red wire to E5V! Care must be taken though, as I don't think is a good thing connecting both the USB micro cable and the DIY cable simultaneously. The workflow would be to flash the board with the micro-connector connected and then unplug and plug in the DIY USB connector to the computer when powering and running the application.