Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

USB MSC example in interrupt mode

I'm experimenting with the USB MSC example (SDK 15.3) on my nRF52840 DK. It seems to work well in the polling mode as delivered. However, when I try to run in interrupt mode it no longer functions properly. The first time I connect the USB cable, Windows 10 recognizes the 3 drives as expected. However, after disconnecting the USB cable, all subsequent attempts to reconnect it fail to bring up the drives. Windows doesn't even see the USB device. During this process the board is constantly powered through the debug USB port. The only way to get the MSC drives working again is to restart the micro.

I assumed the only steps needed to get this working would be to comment would be the ones suggested in this post:

https://devzone.nordicsemi.com/f/nordic-q-a/34933/usb-cdc-acm-example-is-not-working-in-interrupt-mode

All you should have to do to make event handling interrupt driven in SDK v15 is to set APP_USBD_CONFIG_EVENT_QUEUE_ENABLE to 0 in sdk_config.h, and comment out the call to app_usbd_event_queue_process() in main.c

Any assistance getting this resolved would be greatly appreciated!

Parents
  • Hello,

    I see that the thread that you link to died. I have tested, and I see the same behavior as you, but I am not certain that the interrupt handler handles all the events correctly, as it does when you use the event queue. I have asked our SDK team if they can take a look at what you would need to do to use this mode. I will let you know as soon as I know something.

    Best regards,

    Edvin

  • Hello,

    I got the same issue and I made it run by the following lines of code. I have no idea why. I am using SDK 15.3 also.

    /**@brief Function for initializing the usbd. */
    static void usbd_init(void)
    {
        static const app_usbd_config_t usbd_config = 
        {
            .ev_state_proc = usbd_user_ev_handler
        };
    
        app_usbd_serial_num_generate();
           
        ret_code_t err_code = app_usbd_init(&usbd_config);
        APP_ERROR_CHECK(err_code);    
    }
    
    
    static void usbd_start()
    {
        ret_code_t err_code;
    
        app_usbd_class_inst_t const * class_cdc_acm = app_usbd_cdc_acm_class_inst_get(&m_app_cdc_acm);
        err_code = app_usbd_class_append(class_cdc_acm);
        APP_ERROR_CHECK(err_code);
    
        if (USBD_POWER_DETECTION)
        {
            err_code = app_usbd_power_events_enable();
            APP_ERROR_CHECK(err_code);
        }
        else
        {
            NRF_LOG_INFO("[USB]No USB power detection enabled\r\nStarting USB now");
    
            app_usbd_enable();
            app_usbd_start();
        }
    }
    
    
    int main(void)
    {
        ret_code_t err_code;
    
        // Initialize.
        log_init();
        clock_init();
        timers_init();
        uart_init();
        buttons_leds_init();
        usbd_init();
        // It does not work if the function usbd_start() is here.
        //usbd_start();
    
        db_discovery_init();
        power_management_init();
        ble_stack_init();
        gatt_init();
        nus_c_init();
        scan_init();
    
        // Start execution.
        // It works if the function usbd_start() is here
        usbd_start();
        // Do manythings here
        
            printf("BLE UART central example started.\r\n");
        NRF_LOG_INFO("BLE UART central example started.");
        scan_start();
    
        // Enter main loop.
        for (;;)
        {
    //        while (app_usbd_event_queue_process())
    //        {
    //            /* Nothing to do */
    //        }
    
        }
        
    }

    Best regards,

         Duy

Reply
  • Hello,

    I got the same issue and I made it run by the following lines of code. I have no idea why. I am using SDK 15.3 also.

    /**@brief Function for initializing the usbd. */
    static void usbd_init(void)
    {
        static const app_usbd_config_t usbd_config = 
        {
            .ev_state_proc = usbd_user_ev_handler
        };
    
        app_usbd_serial_num_generate();
           
        ret_code_t err_code = app_usbd_init(&usbd_config);
        APP_ERROR_CHECK(err_code);    
    }
    
    
    static void usbd_start()
    {
        ret_code_t err_code;
    
        app_usbd_class_inst_t const * class_cdc_acm = app_usbd_cdc_acm_class_inst_get(&m_app_cdc_acm);
        err_code = app_usbd_class_append(class_cdc_acm);
        APP_ERROR_CHECK(err_code);
    
        if (USBD_POWER_DETECTION)
        {
            err_code = app_usbd_power_events_enable();
            APP_ERROR_CHECK(err_code);
        }
        else
        {
            NRF_LOG_INFO("[USB]No USB power detection enabled\r\nStarting USB now");
    
            app_usbd_enable();
            app_usbd_start();
        }
    }
    
    
    int main(void)
    {
        ret_code_t err_code;
    
        // Initialize.
        log_init();
        clock_init();
        timers_init();
        uart_init();
        buttons_leds_init();
        usbd_init();
        // It does not work if the function usbd_start() is here.
        //usbd_start();
    
        db_discovery_init();
        power_management_init();
        ble_stack_init();
        gatt_init();
        nus_c_init();
        scan_init();
    
        // Start execution.
        // It works if the function usbd_start() is here
        usbd_start();
        // Do manythings here
        
            printf("BLE UART central example started.\r\n");
        NRF_LOG_INFO("BLE UART central example started.");
        scan_start();
    
        // Enter main loop.
        for (;;)
        {
    //        while (app_usbd_event_queue_process())
    //        {
    //            /* Nothing to do */
    //        }
    
        }
        
    }

    Best regards,

         Duy

Children
No Data
Related