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

Help for activating “Softdevice” with “USB CDC ACM”

Hello,

We are trying to upgrade two types of our existing projects with BLE connectivity. For simplifying this help-post, I’m referring only for the simplest project group. Basically our board has a sensor connected to an ADC which interrupts the CPU periodically with the converted results. The results are processed by the application SW on the board, and then sent to an application running on a PC, via USB connection. The PC application replies for each packet from the target, so it isn’t just a dump terminal.

So far:

1 - We bought two NRF52840 SDK board.

2 - Learned from two e-books: “Intro_to_Bluetooth_Low_Energy”   and

    “Bluetooth_5_and_Bluetooth_Low_Energy_-_A_Developer's_Guide”  (by Mohammad Afaneh).

 

3 – We added (“wired”) our ADC and sensor to one of the NRF52840 SDK boards.

4 – Implemented the “Server” role on the first nfr52840 board according to the e-book guide, i.e. using 

      sdk 14.2.0. Also our original “target side” application was added to this board SW.

 

5 – Implemented the “Client” role on the second nfr52840 board according to the e-book guide, i.e.       

       using SDK 14.2.0.

 

6 – Now we can see all characteristics exposed by our user defined service, updated by our application

      on the server board, in the debug window Segger Embedded Studio (SES), as well as in the “nrf     

      Connect” application, (Android and Windows).

 

7 – Expectedly, we want to forward this data to a PC application via USB, and optionally get some data in return from the PC.

However we are stuck here, unable to add the libraries and servers for using the USB hardware on the SDK board.  The problem according to DevZon’s experts is described on the following link:

https://devzone.nordicsemi.com/f/nordic-q-a/19550/can-nrf52840-usbd-work-with-softdevice/75998#75998

“Can nrf52840 usbd work with softdevice?”

over 2 years ago in reply to Sigurd

Hi, the reason for this is that the NRF_POWER interrupts that is set with the usb_start()/nrf_power_int_enable() function are cleared/removed when the SoftDevice is enabled. These interrupts are used to detect when the USB-cable is plugged in and out. The application has restricted access to the NRF_POWER peripheral after the SoftDevice is enabled, so it cannot set-up the interrupts after the SoftDevice is enabled. A new SoftDevice version is soon coming that will have the functionality to set-up these interrupts after the SoftDevice is enabled.

 

So we need an updated example for the “Central” role, running on SDK v15.0.0 (or v15.2.0).

It is really frustrating the usefulness of the old examples (SDK 14.2.0) inside “Bluetooth_5_and_Bluetooth_Low_Energy_-_A_Developer's_Guide”, for   SDK 15.0.0.

The migration process guide supplied by Nordic is too difficult, unacceptable, and it contradicts the Nordics boast to let the programmers be concentrated on developing their own application. Actually it took us just two days to wire our hardware sensors + ADC to the SDK board and migrating our SW to the board. The rest of the time, since my first post on DevZone at 26/08/2018 was spent on fighting with Nordic SW issues.  

  • Hi Sigurd,

    Of course it could be, my windows app do need to use the function RegisterDeviceNotification().

     What a modest person you are! Are you “not familiar” in some other subjects and help me out in that way? Indeed, just after the windows program begun to work perfectly I could be sure about the fact that even after the implementation of RegisterDeviceNotification(), the notifications work only if the Center SDK (where the usbd_cdc_acm is running) is connected to the SES program, and also till the first power-cycle after exiting SES program. 

    Actually I’ve read a similar discussion titled “nrf52832 not working outside debugger

    here at:  https://devzone.nordicsemi.com/f/nordic-q-a/28860/nrf52832-not-working-outside-debugger/114252#114252 (I’m using nrf52840),  and even tried the two controversial solutions but got no remedy from them.

    Thank for advance.

  • Hi,

    I’ve already solved the last problem of “not working outside the debugger”. The solution is simple, as following:

    Before the execution of the lines:

     

    app_usbd_serial_num_generate();
    ret = app_usbd_init(&usbd_config);
    

     

    a delay must be inserted:

    uint32_t x,y=2,z=4;
    for(x = 0; x < 10000000;x++) 
    {
     y = z^4;
    }
     

     (This is not the best delay loop, I just wanted to acquire a delay quickly, while being sure it’s not bypassed by the optimizer...)

     

    The reason is simple too, albeit many of us forgetting it, specially in these days of snippet-mania:

    So, when using the USB cord as a sole power source, the board have zero volt before the cord is plugged in. Immediately after plugging it in, as soon as the voltage rises to 2.7~3 Volt, the MCU begins to fetch opcodes, and actually rushes over the app_usb_init() function before the voltage rises to 5Volt, the level needed to communicate via USB data bus. So the premature request of the USB device to be registered at the USB HOST is doomed, and we wait in wain to the savior “GONG” sound of the device manager for “new device detected” message.  

Related