<?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 peripheral enable</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/32007/usb-peripheral-enable</link><description>Hi, 
 We have recently moved from using the nRF52840 PDK to a custom PCB. The custom PCB uses nRF52840 Q1AABB, while the PDK has Q1AAAA. 
 On the custom PCB, the code is getting stuck in nrf_drv_usbd_enable(). USB power has been detected at this point</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 09 Mar 2018 22:34:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/32007/usb-peripheral-enable" /><item><title>RE: USB peripheral enable</title><link>https://devzone.nordicsemi.com/thread/124042?ContentTypeID=1</link><pubDate>Fri, 09 Mar 2018 22:34:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf14e955-efaa-414b-b55b-a9cc3571718a</guid><dc:creator>jzurasky321</dc:creator><description>&lt;p&gt;Excellent!&amp;nbsp; Applying those changes made it functional on our custom PCB.&amp;nbsp; Closed.&lt;/p&gt;
&lt;p&gt;Thanks for your quick and expert help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB peripheral enable</title><link>https://devzone.nordicsemi.com/thread/124041?ContentTypeID=1</link><pubDate>Fri, 09 Mar 2018 20:20:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51d4d8bb-ac43-44bd-a775-8b1d3a882c50</guid><dc:creator>Jeff4BLE</dc:creator><description>&lt;p&gt;Hi Jacob,&lt;/p&gt;
&lt;p&gt;I understand you have addressed PAN 171. But please allow me to address PAN 171 in this email as well.&lt;/p&gt;
&lt;p&gt;There are 3 versions of the nRF52840 and the related DKs have different errata. To complicate things a bit more there are two DK versions with Rev A devices on them. So knowing what DK version, SDK, and silicon revision being used is extremely important.&amp;nbsp; If this message does not address your issue, please provide all of this information.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Below are&amp;nbsp;patches addressing some of the errata found in the revision B and C silicon. A couple of these patches will be included in SDK15. The use of SKD15 and the related softdevice will be required to use the Nordic QID.&lt;/p&gt;
&lt;p&gt;The three functions below are updated USB functions: nrf_drv_usbd_enable, nrf_drv_usbd_wakeup_req, and nrf_drv_usbd_suspend.&amp;nbsp; These functions from SDK15 will identify the IC and apply the appropriate software changes to resolve various USB errata.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;SDK 14.2 does not support the function calls to nrf_drv_usbd_errata_xxxx.&amp;nbsp; For my use, I removed the parentheses of the function calls and used the following conditional compilation.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;#define DK_0_11_0 1&lt;/p&gt;
&lt;p&gt;// DK 0.11.0 is the newest nrf52840-PDK with Rev B silicon.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;#ifdef&amp;nbsp; DK_0_11_0&lt;/p&gt;
&lt;p&gt;#define nrf_drv_usbd_errata_166 1&lt;/p&gt;
&lt;p&gt;#define nrf_drv_usbd_errata_171 1&lt;/p&gt;
&lt;p&gt;#define nrf_drv_usbd_errata_187 1&lt;/p&gt;
&lt;p&gt;#else&lt;/p&gt;
&lt;p&gt;#define nrf_drv_usbd_errata_166 1&lt;/p&gt;
&lt;p&gt;#define nrf_drv_usbd_errata_171 0&lt;/p&gt;
&lt;p&gt;#define nrf_drv_usbd_errata_187 0&lt;/p&gt;
&lt;p&gt;#endif&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This was a quick and easy solution. I am sure&amp;nbsp;you can crate a more elegant way of accomplishing this.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;With the release of SDK15, we are shifting to a unified and public driver support paradigm. Therefore, some of the #defines have changed from NRF_DRV_xxxx to NRFX_DRV_xxxx. Removing the X will allow the patch to compile with SDK14.2. This also allow SDK14.2 to be used with Rev C devices.&lt;/p&gt;
&lt;p&gt;Going forward NRFX drivers will be maintained on &lt;a href="https://github.com/NordicSemiconductor/nrfx"&gt;github&lt;/a&gt;. This repository is currently the work in progress for drivers to be released in SDK15. If there any issues with the SDK14 drivers, please review the updates on github first.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;The DK with production/rev C devices and SDK15 are both scheduled to be released 3/23 or shortly thereafter.&lt;/p&gt;
&lt;p&gt;Please let me know how this works out for you.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Jeff&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;bool nrf_drv_usbd_suspend(void)&lt;br /&gt;{&lt;br /&gt; bool suspended = false;&lt;/p&gt;
&lt;p&gt;CRITICAL_REGION_ENTER();&lt;br /&gt; if (m_bus_suspend)&lt;br /&gt; {&lt;br /&gt; usbd_ep_abort_all();&lt;/p&gt;
&lt;p&gt;if (!(nrf_usbd_eventcause_get() &amp;amp; NRF_USBD_EVENTCAUSE_RESUME_MASK))&lt;br /&gt; {&lt;br /&gt; nrf_usbd_lowpower_enable();&lt;br /&gt; if (nrf_usbd_eventcause_get() &amp;amp; NRF_USBD_EVENTCAUSE_RESUME_MASK)&lt;br /&gt; {&lt;br /&gt; nrf_usbd_lowpower_disable();&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; suspended = true;&lt;/p&gt;
&lt;p&gt;if (nrf_drv_usbd_errata_171())&lt;br /&gt; {&lt;br /&gt; if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)&lt;br /&gt; {&lt;br /&gt; *((volatile uint32_t *)(0x4006EC00)) = 0x00009375;&lt;br /&gt; *((volatile uint32_t *)(0x4006EC14)) = 0x00000000;&lt;br /&gt; *((volatile uint32_t *)(0x4006EC00)) = 0x00009375;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; *((volatile uint32_t *)(0x4006EC14)) = 0x00000000;&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt; CRITICAL_REGION_EXIT();&lt;/p&gt;
&lt;p&gt;return suspended;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;bool nrf_drv_usbd_wakeup_req(void)&lt;br /&gt;{&lt;br /&gt; bool started = false;&lt;/p&gt;
&lt;p&gt;CRITICAL_REGION_ENTER();&lt;br /&gt; if (m_bus_suspend &amp;amp;&amp;amp; nrf_usbd_lowpower_check())&lt;br /&gt; {&lt;br /&gt; nrf_usbd_lowpower_disable();&lt;br /&gt; started = true;&lt;/p&gt;
&lt;p&gt;if (nrf_drv_usbd_errata_171())&lt;br /&gt; {&lt;br /&gt; if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)&lt;br /&gt; {&lt;br /&gt; *((volatile uint32_t *)(0x4006EC00)) = 0x00009375;&lt;br /&gt; *((volatile uint32_t *)(0x4006EC14)) = 0x000000C0;&lt;br /&gt; *((volatile uint32_t *)(0x4006EC00)) = 0x00009375;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; *((volatile uint32_t *)(0x4006EC14)) = 0x000000C0;&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;}&lt;br /&gt; }&lt;br /&gt; CRITICAL_REGION_EXIT();&lt;/p&gt;
&lt;p&gt;return started;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;void nrf_drv_usbd_enable(void)&lt;br /&gt;{&lt;br /&gt; ASSERT(m_drv_state == NRFX_DRV_STATE_INITIALIZED);&lt;/p&gt;
&lt;p&gt;/* Prepare for READY event receiving */&lt;br /&gt; nrf_usbd_eventcause_clear(NRF_USBD_EVENTCAUSE_READY_MASK);&lt;/p&gt;
&lt;p&gt;if (nrf_drv_usbd_errata_187())&lt;br /&gt; {&lt;br /&gt; CRITICAL_REGION_ENTER();&lt;br /&gt; if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)&lt;br /&gt; {&lt;br /&gt; *((volatile uint32_t *)(0x4006EC00)) = 0x00009375;&lt;br /&gt; *((volatile uint32_t *)(0x4006ED14)) = 0x00000003;&lt;br /&gt; *((volatile uint32_t *)(0x4006EC00)) = 0x00009375;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; *((volatile uint32_t *)(0x4006ED14)) = 0x00000003;&lt;br /&gt; }&lt;br /&gt; CRITICAL_REGION_EXIT();&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; if (nrf_drv_usbd_errata_171())&lt;br /&gt; {&lt;br /&gt; CRITICAL_REGION_ENTER();&lt;br /&gt; if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)&lt;br /&gt; {&lt;br /&gt; *((volatile uint32_t *)(0x4006EC00)) = 0x00009375;&lt;br /&gt; *((volatile uint32_t *)(0x4006EC14)) = 0x000000C0;&lt;br /&gt; *((volatile uint32_t *)(0x4006EC00)) = 0x00009375;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; *((volatile uint32_t *)(0x4006EC14)) = 0x000000C0;&lt;br /&gt; }&lt;br /&gt; CRITICAL_REGION_EXIT();&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;/* Enable the peripheral */&lt;br /&gt; nrf_usbd_enable();&lt;br /&gt; /* Waiting for peripheral to enable, this should take a few us */&lt;br /&gt; while (0 == (NRF_USBD_EVENTCAUSE_READY_MASK &amp;amp; nrf_usbd_eventcause_get()))&lt;br /&gt; {&lt;br /&gt; /* Empty loop */&lt;br /&gt; }&lt;br /&gt; nrf_usbd_eventcause_clear(NRF_USBD_EVENTCAUSE_READY_MASK);&lt;br /&gt; &lt;br /&gt; if (nrf_drv_usbd_errata_171())&lt;br /&gt; {&lt;br /&gt; CRITICAL_REGION_ENTER();&lt;br /&gt; if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)&lt;br /&gt; {&lt;br /&gt; *((volatile uint32_t *)(0x4006EC00)) = 0x00009375;&lt;br /&gt; *((volatile uint32_t *)(0x4006EC14)) = 0x00000000;&lt;br /&gt; *((volatile uint32_t *)(0x4006EC00)) = 0x00009375;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; *((volatile uint32_t *)(0x4006EC14)) = 0x00000000;&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;CRITICAL_REGION_EXIT();&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;if (nrf_drv_usbd_errata_187())&lt;br /&gt; {&lt;br /&gt; CRITICAL_REGION_ENTER();&lt;br /&gt; if (*((volatile uint32_t *)(0x4006EC00)) == 0x00000000)&lt;br /&gt; {&lt;br /&gt; *((volatile uint32_t *)(0x4006EC00)) = 0x00009375;&lt;br /&gt; *((volatile uint32_t *)(0x4006ED14)) = 0x00000000;&lt;br /&gt; *((volatile uint32_t *)(0x4006EC00)) = 0x00009375;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; *((volatile uint32_t *)(0x4006ED14)) = 0x00000000;&lt;br /&gt; }&lt;br /&gt; CRITICAL_REGION_EXIT();&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;if (nrf_drv_usbd_errata_166())&lt;br /&gt; {&lt;br /&gt; *((volatile uint32_t *)(NRF_USBD_BASE + 0x800)) = 0x7E3;&lt;br /&gt; *((volatile uint32_t *)(NRF_USBD_BASE + 0x804)) = 0x40;&lt;br /&gt; __ISB();&lt;br /&gt; __DSB();&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;nrf_usbd_isosplit_set(NRF_USBD_ISOSPLIT_Half);&lt;/p&gt;
&lt;p&gt;m_ep_ready = (((1U &amp;lt;&amp;lt; NRF_USBD_EPIN_CNT) - 1U) &amp;lt;&amp;lt; USBD_EPIN_BITPOS_0);&lt;br /&gt; m_ep_dma_waiting = 0;&lt;br /&gt; m_dma_pending = 0;&lt;br /&gt; m_last_setup_dir = NRF_DRV_USBD_EPOUT0;&lt;/p&gt;
&lt;p&gt;m_drv_state = NRFX_DRV_STATE_POWERED_ON;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB peripheral enable</title><link>https://devzone.nordicsemi.com/thread/124040?ContentTypeID=1</link><pubDate>Fri, 09 Mar 2018 19:42:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a0c869d-c404-4204-8de2-6420c80be46b</guid><dc:creator>jzurasky321</dc:creator><description>&lt;p&gt;Update: I applied errata [171] with no change in behavior.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>