<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>MCX Microcontrollers中的主题 Re: FRDM-MCXN947 Detection of USB_HS Connection</title>
    <link>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXN947-Detection-of-USB-HS-Connection/m-p/1985609#M1877</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/27788"&gt;@Alice_Yang&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I have tried &lt;SPAN&gt;dev_msc_disk_bm,&amp;nbsp;dev_msc_disk_bm_lite and dev_msc_disk_freertos and they all works fine. It looks like it's some configuration issue, my code is based on&amp;nbsp;dev_msc_disk_bm_lite.&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 31 Oct 2024 14:34:22 GMT</pubDate>
    <dc:creator>Doly02</dc:creator>
    <dc:date>2024-10-31T14:34:22Z</dc:date>
    <item>
      <title>FRDM-MCXN947 Detection of USB_HS Connection</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXN947-Detection-of-USB-HS-Connection/m-p/1983939#M1860</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;in my application on FRDM-MCX947 board that's based on FreeRTOS, I try to detect USB_HS using USB stack.&amp;nbsp;I always have a situation that the first connection after starting the program is not detected by the interrupt (it does not jump to the USB1_HS_IRQHandler) and when disconnecting the USB1_HS_IRQHandler is called, the next connection is also detected, but once in a while it drops out again.&lt;/P&gt;&lt;P&gt;In the main function in the initialization phase, I initialize the USB stack and enable the interrupt:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void APP_UsbInit(void)
{
	USB_DeviceClockInit();
    g_msc.speed                      = USB_SPEED_FULL;
    g_msc.attach                     = 0;
    g_msc.deviceHandle               = NULL;

    if (kStatus_USB_Success != USB_DeviceInit(CONTROLLER_ID, USB_DeviceCallback, &amp;amp;g_msc.deviceHandle))
    {
        usb_echo("USB device mass storage init failed\r\n");
        return;
    }
    SDK_DelayAtLeastUs(5000, SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY);

    USB_DeviceIsrEnable();

}

void USB_DeviceIsrEnable(void)
{
    uint8_t irqNumber;
    uint8_t usbDeviceEhciIrq[] = USBHS_IRQS;
    irqNumber                  = usbDeviceEhciIrq[CONTROLLER_ID - kUSB_ControllerEhci0];

    /* Install isr, set priority, and enable IRQ. */
    DisableIRQ((IRQn_Type)irqNumber);
    NVIC_SetPriority((IRQn_Type)irqNumber, USB_DEVICE_INTERRUPT_PRIORITY);
    EnableIRQ((IRQn_Type)irqNumber);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, if a connected USB is detected, I initialize Mass Storage and switch the program to Mass Storage mode using a semaphore, however, it is probably not invoked on the first connection:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void USB1_HS_IRQHandler(void)
{
	BaseType_t xHigherPriorityTaskWoken = pdFALSE;

    if (false == bMscInitialized)
    {
		/* Initialize The Mass Storage Device Application 	*/
		/* @note Initialization SD Card In Device Mode 		*/
        USB_DeviceApplicationInit();
        bMscInitialized = true;
    }
    USB_DeviceEhciIsrFunction(g_msc.deviceHandle);

    /* Free The Mutex For Mass Storage Task */
    xSemaphoreGiveFromISR(g_TaskMutex, &amp;amp;xHigherPriorityTaskWoken);

    /**
     * Switch The Context From ISR To a Higher Priority Task,
     * Without Waiting For The Next Scheduler Tick.
     **/
    portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to ask if there is anything else to add during initialization to make my detection work properly. Thank you in advance for all your advice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 14:46:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXN947-Detection-of-USB-HS-Connection/m-p/1983939#M1860</guid>
      <dc:creator>Doly02</dc:creator>
      <dc:date>2024-10-29T14:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-MCXN947 Detection of USB_HS Connection</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXN947-Detection-of-USB-HS-Connection/m-p/1985474#M1875</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/235054"&gt;@Doly02&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I recommend that you first run the SDK demo dev_msc_disk_bm to check whether it works well on your side. This will help us determine if the issue is specific to your setup or the configuration.&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 09:50:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXN947-Detection-of-USB-HS-Connection/m-p/1985474#M1875</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2024-10-31T09:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-MCXN947 Detection of USB_HS Connection</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXN947-Detection-of-USB-HS-Connection/m-p/1985609#M1877</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/27788"&gt;@Alice_Yang&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I have tried &lt;SPAN&gt;dev_msc_disk_bm,&amp;nbsp;dev_msc_disk_bm_lite and dev_msc_disk_freertos and they all works fine. It looks like it's some configuration issue, my code is based on&amp;nbsp;dev_msc_disk_bm_lite.&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 14:34:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXN947-Detection-of-USB-HS-Connection/m-p/1985609#M1877</guid>
      <dc:creator>Doly02</dc:creator>
      <dc:date>2024-10-31T14:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-MCXN947 Detection of USB_HS Connection</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXN947-Detection-of-USB-HS-Connection/m-p/1985928#M1883</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/235054"&gt;@Doly02&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So, I recommend that you check your modified code. You can try changing one modification at a time to isolate the issue.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;BR&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Alice&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2024 04:23:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXN947-Detection-of-USB-HS-Connection/m-p/1985928#M1883</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2024-11-01T04:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: FRDM-MCXN947 Detection of USB_HS Connection</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXN947-Detection-of-USB-HS-Connection/m-p/1986356#M1887</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/27788"&gt;@Alice_Yang&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thank you for your helpful thought, I wouldn't have figured it out without you.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Nov 2024 16:27:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/FRDM-MCXN947-Detection-of-USB-HS-Connection/m-p/1986356#M1887</guid>
      <dc:creator>Doly02</dc:creator>
      <dc:date>2024-11-01T16:27:05Z</dc:date>
    </item>
  </channel>
</rss>

