This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Issues with writing my own project that communicates with a computer over USB.

Hi,

I've been trying to combine the spi_slave and USB_CDC_ADM examples so that I can pipe data from a spi_master all the way to my host machine. In my cobbled together project, the SPI transactions are working, but the USB isn't being properly sensed by my machine. I keep seeing this in my device manager:

The USB_CDC_ADM example works just fine though.

Any ideas on what I'm messing up? Thank you!

  • Hi Rye, 

    Could you check what's the issue with the nRF52 USB Product (right click and click properties)
    I would suggest to comment out the SPI functionality part by part until you see the USB work again, this way we can track down what caused the issue. 


  • I think it has to do with something in my sdk_config.h. I've removed most of the SPI code now. Aside from defining the SPI handler and enabling the SPI in the SDK_config, the SPI isn't doing anything (i.e. no SPI code in my main). I have the same issue.

    I took a look at the properties tab and there are two events. I've copied both below:

    The first one (Driver name is 'null' which seems like a problem. The drivers should be installed!):

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Device USB\VID_1915&PID_520C\000000000000 was configured.
    Driver Name: null
    Class Guid: {00000000-0000-0000-0000-000000000000}
    Driver Date:
    Driver Version:
    Driver Provider:
    Driver Section:
    Driver Rank: 0x0
    Matching Device Id:
    Outranked Drivers:
    Device Updated: false
    Parent Device: USB\VID_045E&PID_0944\6&15ba3093&0&1
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    The second one:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    Device USB\VID_1915&PID_520C\000000000000 was not migrated due to partial or ambiguous match.
    Last Device Instance Id: USB\VID_0403&PID_6010\003017A40B1B
    Class Guid: {36fc9e60-c465-11cf-8056-444553540000}
    Location Path: PCIROOT(0)#PCI(1400)#USBROOT(0)#USB(1)#USB(1)#USB(2)
    Migration Rank: 0xF000FFFFFFFF0123
    Present: false
    Status: 0xC0000719
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    So it seems maybe I'm messing up some USB params in my sdk_config.h? I'll take a more extensive look through it right now.

  • Okay, the problem was that I wasn't running app_usbd_event_queue_process() to actually process any USB events. I must have accidentally forgotten to copy it over. I have a new issue though. 

    I've set up two dev kits, a SPI master & a SPI slave. The Master sends a message "comes_from_spi_mstr" to the slave, which then pipes it to my desktop via USB. What's weird is that the message makes its way to my computer (I see "comes_from_spi_mstr" on computer from the USB's COM port)... but when I print the SPI's rx buffer through the logger it comes up empty.

    Here are photos to show what's happening:

    SPI logger output:

    USB output:

    Any idea why it's not coming up in the logger, despite being there (as shown by making its way all the way through the USB).

    Thanks,

    Ryan

  • Hi, 
    Please post your code, and state which SDK you are using. 
    Please track down on how you pass the data from SPI to USB.

  • Hi Hung,

    I've attached my main.c and sdkconfig.h. I'm using nRF5 SDK v16.0.0.

    As fare as how data is being passed from the SPI to the USB, I'm just taking the SPI_rx buffer and sprintf-ing it into the USB_tx buffer (corresponding lines copied below):

    Fullscreen
    1
    2
    size_t size = sprintf(m_tx_buffer, "Hello USB CDC demo: %s\r\n", (uint32_t)spi_rx_buf);
    app_usbd_cdc_acm_write(&m_app_cdc_acm, m_tx_buffer, size);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

     

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    /**
    * Copyright (c) 2017 - 2019, Nordic Semiconductor ASA
    *
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without modification,
    * are permitted provided that the following conditions are met:
    *
    * 1. Redistributions of source code must retain the above copyright notice, this
    * list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form, except as embedded into a Nordic
    * Semiconductor ASA integrated circuit in a product or a software update for
    * such product, must reproduce the above copyright notice, this list of
    * conditions and the following disclaimer in the documentation and/or other
    * materials provided with the distribution.
    *
    * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
    * contributors may be used to endorse or promote products derived from this
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    6685.sdk_config.h

1 2