<?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 device suspend/resume issue when requesting HFCLK
 (update)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/79872/usb-device-suspend-resume-issue-when-requesting-hfclk-update</link><description>To the kind attention of Nordic support team, 
 
 Is there any update about this topic: 
 https://devzone.nordicsemi.com/f/nordic-q-a/59738/usb-device-suspend-resume-issue-when-requesting-hfclk ? 
 I think I&amp;#39;m experiencing something like that. I&amp;#39;d like</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 29 Sep 2021 08:04:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/79872/usb-device-suspend-resume-issue-when-requesting-hfclk-update" /><item><title>RE: USB device suspend/resume issue when requesting HFCLK
 (update)</title><link>https://devzone.nordicsemi.com/thread/331631?ContentTypeID=1</link><pubDate>Wed, 29 Sep 2021 08:04:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62b0a2a0-4598-42ec-ae17-bf8c7f180abd</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Stella&lt;/p&gt;
&lt;p&gt;I am still waiting for some input from the USB developer. Apparently he was very busy at the moment, but would try to provide an update by the end of the week.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have also asked for some input from one of my colleagues more knowledgeable about FreeRTOS, to see if we have any previous experience combining FreeRTOS with the USB stack.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB device suspend/resume issue when requesting HFCLK
 (update)</title><link>https://devzone.nordicsemi.com/thread/331437?ContentTypeID=1</link><pubDate>Tue, 28 Sep 2021 08:14:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5b3348d-f50b-440b-98cd-6127ad09e30a</guid><dc:creator>astella</dc:creator><description>&lt;p&gt;I d like to add, yes USB queue processing is really timing demanding sometime but it shouldn&amp;#39;t be a problem if freertos preemption is correctly configured for USB task. So, it is nice to have either USB processing done inside interrupts or freertos preemption accurately configured when USB processing is done inside the queue. Also to have tasks running in a &amp;quot;steady&amp;quot; way, could be nice to use USB interrupt as freertos source. And switch if needed to rtc1 source only when usb is not available / suspended mode. In this way is possible to get usb processing and other tasks to appear in sync even in freertos environment with preemtion/ slice timing enabled&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB device suspend/resume issue when requesting HFCLK
 (update)</title><link>https://devzone.nordicsemi.com/thread/331142?ContentTypeID=1</link><pubDate>Fri, 24 Sep 2021 15:50:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9e1e642-8d74-40da-9e7a-8012ccaf4b2a</guid><dc:creator>astella</dc:creator><description>&lt;p&gt;Thank you very much ovrebekk,&lt;/p&gt;
&lt;p&gt;we like usb interrupt handling as in our case, our freertos project seems to be deterministic:&lt;/p&gt;
&lt;p&gt;(thanks also to segger systemview and &lt;a href="https://wiki.segger.com/FreeRTOS_with_SystemView"&gt;https://wiki.segger.com/FreeRTOS_with_SystemView&lt;/a&gt;&amp;nbsp;for freertos patched files for offering an awesome analyses tool)&lt;/p&gt;
&lt;pre class="tw-data-text tw-text-large XcVN5d tw-ta" id="tw-target-text" dir="ltr"&gt;&lt;/pre&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/out_5F00_of_5F00_curiosity.jpg" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB device suspend/resume issue when requesting HFCLK
 (update)</title><link>https://devzone.nordicsemi.com/thread/331041?ContentTypeID=1</link><pubDate>Fri, 24 Sep 2021 10:46:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13d685ea-7308-49df-b4b3-2b5d2dfe2b72</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Stella&lt;/p&gt;
&lt;p&gt;Thanks for sharing the files. I have asked the developer for some input, and will try to get back to you early next week.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB device suspend/resume issue when requesting HFCLK
 (update)</title><link>https://devzone.nordicsemi.com/thread/330839?ContentTypeID=1</link><pubDate>Thu, 23 Sep 2021 12:13:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0742530-515a-4557-a569-65c5e9b167f9</guid><dc:creator>astella</dc:creator><description>&lt;p&gt;Hi ovrebekk, thank you very much for your kindness.&lt;/p&gt;
&lt;p&gt;these are modifications we are talking about. I&amp;#39;m just enclosing sdk16 files as they have been modified in our test custom project. Hope this suffice to get the idea. Shouldn&amp;#39;t be enough or something is missing from your point of view, I could try to modify an existing SDK project as well.&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/app_5F00_usbd_5F00_hid.h"&gt;devzone.nordicsemi.com/.../app_5F00_usbd_5F00_hid.h&lt;/a&gt;&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/app_5F00_usbd.c"&gt;devzone.nordicsemi.com/.../app_5F00_usbd.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB device suspend/resume issue when requesting HFCLK
 (update)</title><link>https://devzone.nordicsemi.com/thread/330814?ContentTypeID=1</link><pubDate>Thu, 23 Sep 2021 11:11:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5677e52b-efe9-4859-b086-2154cb5a24d9</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Stella&lt;/p&gt;
&lt;p&gt;Could you please attach the modified files to the case so I can more easily have a look at the changes?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then I can make a diff between the original and modified files, and ask the USB developer for some input.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB device suspend/resume issue when requesting HFCLK
 (update)</title><link>https://devzone.nordicsemi.com/thread/330668?ContentTypeID=1</link><pubDate>Wed, 22 Sep 2021 12:47:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c0af648-9431-4e55-aeba-962e15dc917e</guid><dc:creator>astella</dc:creator><description>&lt;div&gt;Hi ovrebekk thank you very much for replaying,&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;as we try to explain in&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/79119/nrf52833-app_usbd_evt_power_ready"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/79119/nrf52833-app_usbd_evt_power_read&lt;/a&gt;&amp;nbsp;, using&amp;nbsp;this simple test we see that there are moment when usb stack timing reaction is really important (during enumeration, for example, and this could be easily solved, doing enumeration before starting scheduler), but we are worried that our freertos configuration can cause random timing problems (especially runtime, should selective suspend/resume interactions be requested by the host).&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;freertos_task{&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; for(){&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; // ... if everything setup feed wdt&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;while (app_usbd_event_queue_process())&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* Nothing to do */&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// for(uint32_t i = 0; i &amp;lt; 3000; i++); // only for test introducing random delay // also vTaskDelay(1) /&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// taskYIELD(); // or test forcinf a context switch here&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// feed wdt here if test delay in usb queue processing&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; }&lt;/div&gt;
&lt;div&gt;}&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;//---------------------------------------------------------------------------------------------------------------------------------&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;This is what we set in sdk config file:&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;#define APP_USBD_CONFIG_EVENT_QUEUE_ENABLE 0&lt;br /&gt;#define APP_USBD_CONFIG_SOF_HANDLING_MODE 2&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;In order to solve the remote wakeup issue when using usb interrupt handling, we used these modifications in our project.&lt;/div&gt;
&lt;div&gt;This seems to be ok for our tests until now, but maybe you can give a better opinion about that:&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Modification #1&lt;br /&gt;\sdk_16-0\components\libraries\usbd\class\hid\app_usbd_hid.h&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;static inline bool app_usbd_hid_trans_required(app_usbd_hid_ctx_t * p_hid_ctx)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; if (app_usbd_hid_state_flag_test(p_hid_ctx, APP_USBD_HID_STATE_FLAG_SUSPENDED) != 0)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(bb == 1)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; aa = 1; // meaning: find out remote wake up going on, just don&amp;#39;t signal it very first time&lt;br /&gt;&amp;nbsp; &amp;nbsp; UNUSED_RETURN_VALUE(app_usbd_wakeup_req());&lt;br /&gt;&amp;nbsp; &amp;nbsp; return false;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt; &amp;nbsp; return app_usbd_hid_state_flag_test(p_hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS) == 0;&lt;br /&gt;}&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Modification #2&lt;br /&gt;\sdk_16-0\components\libraries\usbd\app_usbd.c&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;In app_usbd_event_execute:&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;a)&lt;/div&gt;
&lt;div&gt;&lt;br /&gt; case APP_USBD_EVT_HFCLK_READY:&lt;br /&gt; {&lt;br /&gt;&amp;nbsp; if(aa == 1){&amp;nbsp; // meaning: if remote wake up going on, get started to change execution flow of state machine, as it would&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// be using queue approach&amp;nbsp;&lt;br /&gt;&amp;nbsp; &amp;nbsp; sustate_set(APP_USBD_EVT_DRV_RESUME);&lt;br /&gt;&amp;nbsp; &amp;nbsp; break;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; switch(sustate_get())&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; case SUSTATE_RESUMING:&lt;br /&gt;&amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; sustate_set(SUSTATE_ACTIVE);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp;case SUSTATE_WAKINGUP_WAITING_HFCLK_WREQ:&lt;br /&gt;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;sustate_set(SUSTATE_WAKINGUP_WAITING_WREQ);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;break;&lt;br /&gt;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; &amp;nbsp;case SUSTATE_WAKINGUP_WAITING_HFCLK:&lt;br /&gt;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;sustate_set(SUSTATE_ACTIVE);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;break;&lt;br /&gt;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; &amp;nbsp;default:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;break; // Just ignore - it can happen in specific situation&lt;br /&gt;&amp;nbsp; }&lt;br /&gt; break;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;b)&lt;br /&gt;&lt;br /&gt;case APP_USBD_EVT_DRV_WUREQ:&lt;br /&gt; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; static const app_usbd_evt_t evt_data = {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.type = APP_USBD_EVT_DRV_RESUME&lt;br /&gt;&amp;nbsp; &amp;nbsp; };&lt;br /&gt;&amp;nbsp; &amp;nbsp; user_event_state_proc(APP_USBD_EVT_DRV_RESUME);&lt;br /&gt;&amp;nbsp; &amp;nbsp; /* Processing core interface (connected only to EP0) and then all instances from the list */&lt;br /&gt;&amp;nbsp; &amp;nbsp; UNUSED_RETURN_VALUE(app_usbd_core_handler_call((app_usbd_internal_evt_t const *)&amp;amp;evt_data));&lt;br /&gt;&amp;nbsp; &amp;nbsp; app_usbd_all_call((app_usbd_complex_evt_t const *)&amp;amp;evt_data);&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; if(aa == 1){&amp;nbsp;&amp;nbsp;&lt;span&gt;// meaning: if remote wake up going on, get started to change execution flow of state machine, as it would&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// be using queue approach&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; aa = 0;&lt;/div&gt;
&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sustate_set(SUSTATE_ACTIVE);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;switch(sustate_get())&lt;br /&gt;&amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; case SUSTATE_WAKINGUP_WAITING_HFCLK_WREQ:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sustate_set(SUSTATE_WAKINGUP_WAITING_HFCLK);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; case SUSTATE_WAKINGUP_WAITING_WREQ:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sustate_set(SUSTATE_ACTIVE);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;default:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* This should not happen - but try to recover by setting directly active state */&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NRF_LOG_WARNING(&amp;quot;Unexpected state on WUREQ event (%u)&amp;quot;, sustate_get());&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sustate_set(SUSTATE_ACTIVE);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp;}&lt;br /&gt; break;&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Best regards&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: USB device suspend/resume issue when requesting HFCLK
 (update)</title><link>https://devzone.nordicsemi.com/thread/330665?ContentTypeID=1</link><pubDate>Wed, 22 Sep 2021 12:37:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87a94f23-c86b-46cd-959d-df6ac20f229f</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Stella&lt;/p&gt;
&lt;p&gt;I checked the internal ticket, but there doesn&amp;#39;t seem to be a resolution unfortunately.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
[quote user=""]I think I&amp;#39;m experiencing something like that. I&amp;#39;d like to avoid usb queue handling in freertos environment,[/quote]
&lt;p&gt;Why is the USB queue handling a problem if you are running freeRTOS?&lt;/p&gt;
&lt;p&gt;Can&amp;#39;t you just set up a separate thread to handle the USB events?&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>