USB configuration

Hi
I have a question regarding USB port on the nrf52840 device
When connecting a new device to computer is it possible to tell PC
to assigne the same COM port number as last Nordic device connected ?

Regards
Olav

  • Hi Olav

    Unfortunately this is controlled by the host (PC), and you can't influence this from the device side. 

    There is some more information in this thread.

    Depending on how you are connecting to the comport from the host side, it might be possible to refer to the product name rather than the comport number. The product name should stay the same even if the comport number changes. 

    Best regards
    Torbjørn

  • Thanks,

    We'll look into the explanation and hints in the thread

    However, is it possible to alter some of the variables in the USB
    descriptor in order to make two devices look "identical" ?

    Hence computer will enumerate the same COM port each time ?

    /**
     @brief Default device descriptor initializer @ref app_usbd_descriptor_device_t
    * */
    #define APP_USBD_CORE_DEVICE_DESCRIPTOR  {                                                                               
       .bLength = sizeof(app_usbd_descriptor_device_t),                     /* descriptor size */                            
       .bDescriptorType = APP_USBD_DESCRIPTOR_DEVICE,         /* descriptor type */                            
       .bcdUSB = APP_USBD_BCD_VER_MAKE(2,0,0),                        /* USB BCD version: 2.0 */                       
       .bDeviceClass = 0,                                                                               /* device class: 0 - specified by interface */   
       .bDeviceSubClass = 0,                                                                       /* device subclass: 0 - specified by interface */
       .bDeviceProtocol = 0,                                                                           /* device protocol: 0 - specified by interface */
       .bMaxPacketSize0 = NRF_DRV_USBD_EPSIZE,                          /* endpoint size: fixed to: NRF_DRV_USBD_EPSIZE*/
       .idVendor = APP_USBD_VID,                                                             /* Vendor ID*/                                   
       .idProduct = APP_USBD_PID,                                                           /* Product ID*/                                  
       .bcdDevice = APP_USBD_BCD_VER_MAKE(                                /* Device version BCD */
           APP_USBD_DEVICE_VER_MAJOR,                                                                                                          
           APP_USBD_DEVICE_VER_MINOR,                                                                       
           APP_USBD_DEVICE_VER_SUB),                                                                        
       .iManufacturer = APP_USBD_STRING_ID_MANUFACTURER,   /* String ID: manufacturer */                   
       .iProduct = APP_USBD_STRING_ID_PRODUCT,                          /* String ID: product */                         
       .iSerialNumber = APP_USBD_STRING_ID_SERIAL,                    /* String ID: serial */                          
       .bNumConfigurations = 1                                                                     /* Fixed value: only one configuration supported*/
    }

    Kind regards

    Olav

  • Hi Olav

    Assuming all your devices use the same firmware, they will use the same USB descriptors. 

    You just have to make sure that your product uses a descriptor that is unique to your product only, and doesn't get mixed up with any other USB devices already on the market. 

    In order to set the product ID string you have to change the following segment in sdk_config.h:

    // <i> Note: This value is not editable in Configuration Wizard.
    // <i> List of product names that is defined the same way like in @ref APP_USBD_STRINGS_MANUFACTURER.
    #ifndef APP_USBD_STRINGS_PRODUCT
    #define APP_USBD_STRINGS_PRODUCT APP_USBD_STRING_DESC("nRF52 USB CDC Demo")
    #endif
    

    Best regards
    Torbjørn

  • You welcome Olav, the best of luck with your project Slight smile

Related