<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>USB DMA</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66583/usb-dma</link><description>when I use usb to transfer, i fine many datas are lost.Is it because the DMA size is too small?Where can i see the dma size?(In nrf52833/examples/peripheral/usb_cdc_acm ).Thanks.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 15 Oct 2020 07:42:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66583/usb-dma" /><item><title>RE: USB DMA</title><link>https://devzone.nordicsemi.com/thread/274994?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2020 07:42:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a744412b-57ca-4110-9385-f279b6deea02</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I assume that is handled in&amp;nbsp;nrfx_usbd_irq_handler():&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/** @brief USBD events. */
typedef enum
{
    NRF_USBD_EVENT_USBRESET      = offsetof(NRF_USBD_Type, EVENTS_USBRESET   ), /**&amp;lt; Signals that a USB reset condition is detected on the USB lines. */
    NRF_USBD_EVENT_STARTED       = offsetof(NRF_USBD_Type, EVENTS_STARTED    ), /**&amp;lt; Confirms that the EPIN[n].PTR, EPIN[n].MAXCNT, EPIN[n].CONFIG, or EPOUT[n].PTR, EPOUT[n].MAXCNT, and EPOUT[n].CONFIG registers have been captured on all endpoints reported in the EPSTATUS register. */
    NRF_USBD_EVENT_ENDEPIN0      = offsetof(NRF_USBD_Type, EVENTS_ENDEPIN[0] ), /**&amp;lt; The whole EPIN[0] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDEPIN1      = offsetof(NRF_USBD_Type, EVENTS_ENDEPIN[1] ), /**&amp;lt; The whole EPIN[1] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDEPIN2      = offsetof(NRF_USBD_Type, EVENTS_ENDEPIN[2] ), /**&amp;lt; The whole EPIN[2] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDEPIN3      = offsetof(NRF_USBD_Type, EVENTS_ENDEPIN[3] ), /**&amp;lt; The whole EPIN[3] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDEPIN4      = offsetof(NRF_USBD_Type, EVENTS_ENDEPIN[4] ), /**&amp;lt; The whole EPIN[4] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDEPIN5      = offsetof(NRF_USBD_Type, EVENTS_ENDEPIN[5] ), /**&amp;lt; The whole EPIN[5] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDEPIN6      = offsetof(NRF_USBD_Type, EVENTS_ENDEPIN[6] ), /**&amp;lt; The whole EPIN[6] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDEPIN7      = offsetof(NRF_USBD_Type, EVENTS_ENDEPIN[7] ), /**&amp;lt; The whole EPIN[7] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_EP0DATADONE   = offsetof(NRF_USBD_Type, EVENTS_EP0DATADONE), /**&amp;lt; An acknowledged data transfer has taken place on the control endpoint. */
    NRF_USBD_EVENT_ENDISOIN0     = offsetof(NRF_USBD_Type, EVENTS_ENDISOIN   ), /**&amp;lt; The whole ISOIN buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDEPOUT0     = offsetof(NRF_USBD_Type, EVENTS_ENDEPOUT[0]), /**&amp;lt; The whole EPOUT[0] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDEPOUT1     = offsetof(NRF_USBD_Type, EVENTS_ENDEPOUT[1]), /**&amp;lt; The whole EPOUT[1] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDEPOUT2     = offsetof(NRF_USBD_Type, EVENTS_ENDEPOUT[2]), /**&amp;lt; The whole EPOUT[2] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDEPOUT3     = offsetof(NRF_USBD_Type, EVENTS_ENDEPOUT[3]), /**&amp;lt; The whole EPOUT[3] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDEPOUT4     = offsetof(NRF_USBD_Type, EVENTS_ENDEPOUT[4]), /**&amp;lt; The whole EPOUT[4] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDEPOUT5     = offsetof(NRF_USBD_Type, EVENTS_ENDEPOUT[5]), /**&amp;lt; The whole EPOUT[5] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDEPOUT6     = offsetof(NRF_USBD_Type, EVENTS_ENDEPOUT[6]), /**&amp;lt; The whole EPOUT[6] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDEPOUT7     = offsetof(NRF_USBD_Type, EVENTS_ENDEPOUT[7]), /**&amp;lt; The whole EPOUT[7] buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_ENDISOOUT0    = offsetof(NRF_USBD_Type, EVENTS_ENDISOOUT  ), /**&amp;lt; The whole ISOOUT buffer has been consumed. The RAM buffer can be accessed safely by software. */
    NRF_USBD_EVENT_SOF           = offsetof(NRF_USBD_Type, EVENTS_SOF        ), /**&amp;lt; Signals that a SOF (start of frame) condition has been detected on the USB lines. */
    NRF_USBD_EVENT_USBEVENT      = offsetof(NRF_USBD_Type, EVENTS_USBEVENT   ), /**&amp;lt; An event or an error not covered by the specified events has occurred, check EVENTCAUSE register to find the cause. */
    NRF_USBD_EVENT_EP0SETUP      = offsetof(NRF_USBD_Type, EVENTS_EP0SETUP   ), /**&amp;lt; A valid SETUP token has been received (and acknowledged) on the control endpoint. */
    NRF_USBD_EVENT_DATAEP        = offsetof(NRF_USBD_Type, EVENTS_EPDATA     ), /**&amp;lt; A data transfer has occurred on a data endpoint, indicated by the EPDATASTATUS register. */
}nrf_usbd_event_t;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB DMA</title><link>https://devzone.nordicsemi.com/thread/274967?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2020 03:18:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:571bf391-9443-495f-aebd-84ab337c810b</guid><dc:creator>yangyongkai</dc:creator><description>&lt;p&gt;Thank you for your reply,There is another question:How do I know that the DMA transfer is over，Is there a transmission end flag and where&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB DMA</title><link>https://devzone.nordicsemi.com/thread/273456?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2020 11:05:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:312096fd-9db0-4a52-8c9b-63a5239d2257</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Please see my comments on how to use the high level api to buffer and send/receive data. I do&amp;nbsp;not think it is a good idea to start modify or play around with the low level usb drivers.&lt;/p&gt;
&lt;p&gt;I can see that the code you refer to have the following define:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#ifndef NRFX_USBD_EARLY_DMA_PROCESS
/* Try to process DMA request when endpoint transmission has been detected
 * and just after last EasyDMA has been processed.
 * It speeds up the transmission a little (about 10% measured)
 * with a cost of more CPU power used.
 */
#define NRFX_USBD_EARLY_DMA_PROCESS 1
#endif&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB DMA</title><link>https://devzone.nordicsemi.com/thread/273345?ContentTypeID=1</link><pubDate>Wed, 07 Oct 2020 05:19:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15d0e340-c4dc-4bae-a4ed-437ae397a353</guid><dc:creator>yangyongkai</dc:creator><description>&lt;p&gt;When I use Putty to send data to the NRF52833 through usb，it&amp;nbsp;keeps reminding &amp;quot;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;USB DMA process - EasyDMA busy&lt;/span&gt;&amp;quot;,Is this related to missing datas？&lt;/div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void usbd_dmareq_process(void)
{
    if (!m_dma_pending)
    {
        uint32_t req;
        while (0 != (req = m_ep_dma_waiting &amp;amp; m_ep_ready))
        {
            uint8_t pos;
            if (NRFX_USBD_CONFIG_DMASCHEDULER_ISO_BOOST &amp;amp;&amp;amp; ((req &amp;amp; USBD_EPISO_BIT_MASK) != 0))
            {
                pos = usbd_dma_scheduler_algorithm(req &amp;amp; USBD_EPISO_BIT_MASK);
            }
            else
            {
                pos = usbd_dma_scheduler_algorithm(req);
            }
            nrfx_usbd_ep_t ep = bit2ep(pos);
            usbd_ep_state_t * p_state = ep_state_access(ep);

            nrfx_usbd_ep_transfer_t transfer;
            bool continue_transfer;

            NRFX_STATIC_ASSERT(offsetof(usbd_ep_state_t, handler.feeder) ==
                offsetof(usbd_ep_state_t, handler.consumer));
            NRFX_ASSERT((p_state-&amp;gt;handler.feeder) != NULL);

            if (NRF_USBD_EPIN_CHECK(ep))
            {
                /* Device -&amp;gt; Host */
                continue_transfer = p_state-&amp;gt;handler.feeder(
                    &amp;amp;transfer,
                    p_state-&amp;gt;p_context,
                    p_state-&amp;gt;max_packet_size);

                if (!continue_transfer)
                {
                    p_state-&amp;gt;handler.feeder = NULL;
                }
            }
            else
            {
                /* Host -&amp;gt; Device */
                const size_t rx_size = nrfx_usbd_epout_size_get(ep);
                continue_transfer = p_state-&amp;gt;handler.consumer(
                    &amp;amp;transfer,
                    p_state-&amp;gt;p_context,
                    p_state-&amp;gt;max_packet_size,
                    rx_size);

                if (transfer.p_data.rx == NULL)
                {
                    /* Dropping transfer - allow processing */
                    NRFX_ASSERT(transfer.size == 0);
                }
                else if (transfer.size &amp;lt; rx_size)
                {
                    NRFX_LOG_DEBUG(&amp;quot;Endpoint %x overload (r: %u, e: %u)&amp;quot;, ep, rx_size, transfer.size);
                    p_state-&amp;gt;status = NRFX_USBD_EP_OVERLOAD;
                    (void)(NRFX_ATOMIC_FETCH_AND(&amp;amp;m_ep_dma_waiting, ~(1U &amp;lt;&amp;lt; pos)));
                    NRFX_USBD_EP_TRANSFER_EVENT(evt, ep, NRFX_USBD_EP_OVERLOAD);
                    m_event_handler(&amp;amp;evt);
                    /* This endpoint will not be transmitted now, repeat the loop */
                    continue;
                }
                else
                {
                    /* Nothing to do - only check integrity if assertions are enabled */
                    NRFX_ASSERT(transfer.size == rx_size);
                }

                if (!continue_transfer)
                {
                    p_state-&amp;gt;handler.consumer = NULL;
                }
            }

            usbd_dma_pending_set();
            m_ep_ready &amp;amp;= ~(1U &amp;lt;&amp;lt; pos);
            if (NRFX_USBD_ISO_DEBUG || (!NRF_USBD_EPISO_CHECK(ep)))
            {
                NRFX_LOG_DEBUG(
                    &amp;quot;USB DMA process: Starting transfer on EP: %x, size: %u&amp;quot;,
                    ep,
                    transfer.size);
            }
            /* Update number of currently transferred bytes */
            p_state-&amp;gt;transfer_cnt += transfer.size;
            /* Start transfer to the endpoint buffer */
            nrf_usbd_ep_easydma_set(ep, transfer.p_data.addr, (uint32_t)transfer.size);

            if (nrfx_usbd_errata_104())
            {
                uint32_t cnt_end = (uint32_t)(-1);
                do
                {
                    uint32_t cnt = (uint32_t)(-1);
                    do
                    {
                        nrf_usbd_event_clear(NRF_USBD_EVENT_STARTED);
                        usbd_dma_start(ep);
                        nrfx_systick_delay_us(2);
                        ++cnt;
                    }while (!nrf_usbd_event_check(NRF_USBD_EVENT_STARTED));
                    if (cnt)
                    {
                        NRFX_USBD_LOG_PROTO1_FIX_PRINTF(&amp;quot;   DMA restarted: %u times&amp;quot;, cnt);
                    }

                    nrfx_systick_delay_us(30);
                    while (0 == (0x20 &amp;amp; *((volatile uint32_t *)(NRF_USBD_BASE + 0x474))))
                    {
                        nrfx_systick_delay_us(2);
                    }
                    nrfx_systick_delay_us(1);

                    ++cnt_end;
                } while (!nrf_usbd_event_check(nrfx_usbd_ep_to_endevent(ep)));
                if (cnt_end)
                {
                    NRFX_USBD_LOG_PROTO1_FIX_PRINTF(&amp;quot;   DMA fully restarted: %u times&amp;quot;, cnt_end);
                }
            }
            else
            {
                usbd_dma_start(ep);
                /* 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)) &amp;amp;&amp;amp;
                       !nrf_usbd_event_check(NRF_USBD_EVENT_USBRESET))
                {
                    /* Empty */
                }
            }

            if (NRFX_USBD_DMAREQ_PROCESS_DEBUG)
            {
                NRFX_LOG_DEBUG(&amp;quot;USB DMA process - finishing&amp;quot;);
            }
            /* Transfer started - exit the loop */
            break;
        }
    }
    else
    {
        if (NRFX_USBD_DMAREQ_PROCESS_DEBUG)
        {
            NRFX_LOG_DEBUG(&amp;quot;USB DMA process - EasyDMA busy&amp;quot;);
        }
    }
}&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB DMA</title><link>https://devzone.nordicsemi.com/thread/272569?ContentTypeID=1</link><pubDate>Thu, 01 Oct 2020 13:30:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dbecab3b-f002-4305-88c2-01d0f0c6742b</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I think you should look at the return codes of app_usbd_cdc_acm_write() and&amp;nbsp;app_usbd_cdc_acm_read(). I suspect&amp;nbsp;data is lost because error codes are ignored or not handled (e.g. you should buffer data and retry if the return code is not success).&lt;/p&gt;
&lt;p&gt;Also check out the documentation and another devzone case below:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/lib_usbd_class_cdc.html"&gt;https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/lib_usbd_class_cdc.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/23265/max-frame-size-usb-bulk-transmision-increase-speed"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/23265/max-frame-size-usb-bulk-transmision-increase-speed&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>