<?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>Detecting USB Power on VBUS pin</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/118031/detecting-usb-power-on-vbus-pin</link><description>I am using a nrf52833 with NCS and was wondering if there are events I can subscribe to (or polling if events don&amp;#39;t exist) that will notify me when USB power is connected/plugged in ? This would have to detect the USB power supplied to the device (on</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 16 Jan 2025 14:20:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/118031/detecting-usb-power-on-vbus-pin" /><item><title>RE: Detecting USB Power on VBUS pin</title><link>https://devzone.nordicsemi.com/thread/518665?ContentTypeID=1</link><pubDate>Thu, 16 Jan 2025 14:20:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ff451f3-d3e8-4454-8481-9a9e203a102b</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;To subscribe to the USBDETECTED event you need to enable the interrupt for it. From the HW level registers you could do something like the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;
&lt;div&gt;Enable the USBDETECTED interrupt using the INTENSET register:&lt;/div&gt;
&lt;div&gt;Set the USBDETECTED bit in the INTENSET register of the POWER peripheral. This can be done by writing a 1 to bit 4 of the INTENSET register.&lt;/div&gt;
&lt;div&gt;
&lt;div dir="ltr"&gt;
&lt;div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;NRF_POWER-&amp;gt;INTENSET = POWER_INTENSET_USBDETECTED_Msk;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;
&lt;div&gt;Implement an interrupt handler for the POWER peripheral events.&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;
&lt;div&gt;In your interrupt handler, check if the USBDETECTED event has occurred:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;if (NRF_POWER-&amp;gt;EVENTS_USBDETECTED)
{
// Handle the USBDETECTED event
NRF_POWER-&amp;gt;EVENTS_USBDETECTED = 0; // Clear the event
}&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div dir="ltr"&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;
&lt;div&gt;Remember to enable the POWER peripheral interrupt in the NVIC (Nested Vectored Interrupt Controller).&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Also, please check out the pull request here that aims to implements this functionality directly in Zephyr.&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/issues/51034"&gt;https://github.com/zephyrproject-rtos/zephyr/issues/51034&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Detecting USB Power on VBUS pin</title><link>https://devzone.nordicsemi.com/thread/518531?ContentTypeID=1</link><pubDate>Thu, 16 Jan 2025 01:25:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d71bdd9c-bae6-4952-9af8-236e8096b9e2</guid><dc:creator>eb12345</dc:creator><description>&lt;p&gt;How do you subscribe to these two events ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Detecting USB Power on VBUS pin</title><link>https://devzone.nordicsemi.com/thread/518428?ContentTypeID=1</link><pubDate>Wed, 15 Jan 2025 11:59:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58e19699-e50b-4585-9891-d90b1dbeaf15</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Yes, there are two VBUS detection events you can use. We have the USBDETECTED event and USBREMOVED event that gets reported when a rising or decreasing voltage on VBUS is detected. When&amp;nbsp;n VBUS rises into its valid range, the software is notified through a USBDETECTED event. A USBREMOVED event is sent when VBUS goes below its valid range. Use these events to implement the USBD start-up sequence described in the USBD chapter of the nRF52833&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf52833/page/keyfeatures_html5.html"&gt;product specifigation&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>