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 HID crash when ESB is used

I want to develop a 2.4G mouse Dongle and  have used NRF52840 and SDK 17.0.2. When I have used USB or ESB one by one - all is Ok. But when they are used together - usb driver goes into an infinite loop here:

 nrfx_usbd.c Line 1447

static void usbd_dmareq_process(void)
{
   ...

   /* There is a lot of USBD registers that cannot be accessed during EasyDMA transfer.
             * This is quick fix to maintain stability of the stack.
             * It cost some performance but makes stack stable. */
             
    while (!nrf_usbd_event_check(nrfx_usbd_ep_to_endevent(ep)) &&
           !nrf_usbd_event_check(NRF_USBD_EVENT_USBRESET))
    {
        /* Empty */        // ***** stay in here *****
    }
   ...          
}

I enqueue the received mouse data in the ESB receiving event, and then dequeue the data in the main loop and transfer it to the PC via USB,USB crashes after running for a while 。

 It seems that the USB has been waiting for the End point 1 transmission completion event :

NRF_USBD_EVENT_ENDEPIN1 /**< The whole EPIN[1] buffer has been consumed. The RAM buffer can be accessed safely by software. */

The call stack when the program crashes is as follows :

Please tell me how to solve this problem 。
 

Parents
  • Hi,

     

    It looks like you are sending HID data prior to eventually the USBD interrupt fires after interrupts are enabled; then ending up in the while-loop.

    Do you have preprocessor defines "DEBUG_NRF" and "DEBUG" set in your project? If not, could you please set these?

     

    I do not see anything related to ESB in your stack trace, but do note that the radio and esb evt handler runs on isr priority 1 and 2 by default, while your usbd runs on 6 (sdk_config.h::USBD_CONFIG_IRQ_PRIORITY)

     

    How long do you need to run the device before this occurs?

    Have you tried to run this on a nRF52840-DK and see if the same issue occurs then?

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    It looks like you are sending HID data prior to eventually the USBD interrupt fires after interrupts are enabled; then ending up in the while-loop.

    Do you have preprocessor defines "DEBUG_NRF" and "DEBUG" set in your project? If not, could you please set these?

     

    I do not see anything related to ESB in your stack trace, but do note that the radio and esb evt handler runs on isr priority 1 and 2 by default, while your usbd runs on 6 (sdk_config.h::USBD_CONFIG_IRQ_PRIORITY)

     

    How long do you need to run the device before this occurs?

    Have you tried to run this on a nRF52840-DK and see if the same issue occurs then?

     

    Kind regards,

    Håkon

Children
Related