<?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>MCUXpresso SDK中的主题 Re: Code examples do not take into account &amp;quot;parallel&amp;quot; access from main() and USB ISR.</title>
    <link>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2173118#M5335</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Hi Edwin,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;First of all, I would like to apologize for indicating an unofficial repository. When I was just getting started with NXP-chips, a friend recommended setting up MCUXpresso IDE exactly with it. I had no idea it was an unofficial repository:(&lt;/P&gt;&lt;P&gt;In the official repository I don't see interruptInPipeStall and interruptInPipeDataBuffer fields, in the use of which I noticed a problem. So, I don't know if it makes sense to continue the discussion:)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code is executed in the main() context:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;usb_status_t USB_DeviceHidSend( class_handle_t handle, uint8_t ep, uint8_t* buffer, uint32_t length )
{
	usb_device_hid_struct_t* hidHandle;
	usb_status_t error = kStatus_USB_Error;

	if ( NULL == handle )
		return kStatus_USB_InvalidHandle;

	hidHandle = (usb_device_hid_struct_t*)handle;

	if ( 0U != hidHandle-&amp;gt;interruptInPipeBusy )
		return kStatus_USB_Busy;

	hidHandle-&amp;gt;interruptInPipeBusy = 1U;

	if ( 0U != hidHandle-&amp;gt;interruptInPipeStall )
	{
		hidHandle-&amp;gt;interruptInPipeDataBuffer = buffer;
		hidHandle-&amp;gt;interruptInPipeDataLen = length;
		return kStatus_USB_Success;
	}

	error = USB_DeviceSendRequest( hidHandle-&amp;gt;handle, ep, buffer, length );
	if ( kStatus_USB_Success != error )
		hidHandle-&amp;gt;interruptInPipeBusy = 0U;

	return error;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the following code is executed under USB-ISR:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;case kUSB_DeviceClassEventSetEndpointHalt:
	if ( ( NULL == hidHandle-&amp;gt;configStruct ) || ( NULL == hidHandle-&amp;gt;interfaceHandle ) )
		break;
	/* Get the endpoint address */
	temp8 = ( (uint8_t*)param );
	for ( count = 0U; count &amp;lt; hidHandle-&amp;gt;interfaceHandle-&amp;gt;endpointList.count; count++ )
	{
		if ( *temp8 == hidHandle-&amp;gt;interfaceHandle-&amp;gt;endpointList.endpoint[count].endpointAddress )
		{
			/* Only stall the endpoint belongs to the class */
			if ( USB_IN == ( ( hidHandle-&amp;gt;interfaceHandle-&amp;gt;endpointList.endpoint[count].endpointAddress &amp;amp; USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK ) &amp;gt;&amp;gt; USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT ) )
				hidHandle-&amp;gt;interruptInPipeStall = 1U;
			else
				hidHandle-&amp;gt;interruptOutPipeStall = 1U;
			error = USB_DeviceStallEndpoint( hidHandle-&amp;gt;handle, *temp8 );
		}
	}
	break;
case kUSB_DeviceClassEventClearEndpointHalt:
	if ( ( NULL == hidHandle-&amp;gt;configStruct ) || ( NULL == hidHandle-&amp;gt;interfaceHandle ) )
		break;
	/* Get the endpoint address */
	temp8 = ( (uint8_t*)param );
	for ( count = 0U; count &amp;lt; hidHandle-&amp;gt;interfaceHandle-&amp;gt;endpointList.count; count++ )
	{
		if ( *temp8 == hidHandle-&amp;gt;interfaceHandle-&amp;gt;endpointList.endpoint[count].endpointAddress )
		{
			/* Only un-stall the endpoint belongs to the class */
			error = USB_DeviceUnstallEndpoint( hidHandle-&amp;gt;handle, *temp8 );
			if ( USB_IN == ( ( ( *temp8 ) &amp;amp; USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK ) &amp;gt;&amp;gt;
				USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT ) )
			{
				if ( 0U != hidHandle-&amp;gt;interruptInPipeStall )
				{
					hidHandle-&amp;gt;interruptInPipeStall = 0U;
					if ( (uint8_t*)USB_INVALID_TRANSFER_BUFFER != hidHandle-&amp;gt;interruptInPipeDataBuffer )
					{
						error = USB_DeviceSendRequest( hidHandle-&amp;gt;handle, ( hidHandle-&amp;gt;interfaceHandle-&amp;gt;endpointList.endpoint[count].endpointAddress &amp;amp; USB_DESCRIPTOR_ENDPOINT_ADDRESS_NUMBER_MASK ), hidHandle-&amp;gt;interruptInPipeDataBuffer, hidHandle-&amp;gt;interruptInPipeDataLen );
						if ( kStatus_USB_Success != error )
						{
							usb_device_endpoint_callback_message_struct_t endpointCallbackMessage;
							endpointCallbackMessage.buffer = hidHandle-&amp;gt;interruptInPipeDataBuffer;
							endpointCallbackMessage.length = hidHandle-&amp;gt;interruptInPipeDataLen;
							endpointCallbackMessage.isSetup = 0U;
							USB_DeviceHidInterruptIn( hidHandle-&amp;gt;handle, (void*)&amp;amp;endpointCallbackMessage, handle );
						}
						hidHandle-&amp;gt;interruptInPipeDataBuffer = (uint8_t*)USB_INVALID_TRANSFER_BUFFER;
						hidHandle-&amp;gt;interruptInPipeDataLen = 0U;
					}
				}
			}
			else
			{
				if ( 0U != hidHandle-&amp;gt;interruptOutPipeStall )
				{
					hidHandle-&amp;gt;interruptOutPipeStall = 0U;
					if ( (uint8_t*)USB_INVALID_TRANSFER_BUFFER != hidHandle-&amp;gt;interruptOutPipeDataBuffer )
					{
						error = USB_DeviceRecvRequest( hidHandle-&amp;gt;handle, ( hidHandle-&amp;gt;interfaceHandle-&amp;gt;endpointList.endpoint[count].endpointAddress &amp;amp; USB_DESCRIPTOR_ENDPOINT_ADDRESS_NUMBER_MASK ), hidHandle-&amp;gt;interruptOutPipeDataBuffer, hidHandle-&amp;gt;interruptOutPipeDataLen );
						if ( kStatus_USB_Success != error )
						{
							usb_device_endpoint_callback_message_struct_t endpointCallbackMessage;
							endpointCallbackMessage.buffer = hidHandle-&amp;gt;interruptOutPipeDataBuffer;
							endpointCallbackMessage.length = hidHandle-&amp;gt;interruptOutPipeDataLen;
							endpointCallbackMessage.isSetup = 0U;
							USB_DeviceHidInterruptOut( hidHandle-&amp;gt;handle, (void*)&amp;amp;endpointCallbackMessage, handle );
						}
						hidHandle-&amp;gt;interruptOutPipeDataBuffer = (uint8_t*)USB_INVALID_TRANSFER_BUFFER;
						hidHandle-&amp;gt;interruptOutPipeDataLen = 0U;
					}
				}
			}
		}
	}
	break;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If during main() execution an interrupt is triggered at this point:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="olex_0-1758445645075.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/357837i2CE3D10084BA9D27/image-size/medium?v=v2&amp;amp;px=400" role="button" title="olex_0-1758445645075.png" alt="olex_0-1758445645075.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;olex_0-1758445645075.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;, and this interrupt handles kUSB_DeviceClassEventClearEndpointHalt event, then the pointer to a some buffer will be saved in interruptInPipeDataBuffer and interruptInPipeDataLen fields.&lt;/P&gt;&lt;P&gt;And this information will be "hidden/waiting" until the next pair of events&amp;nbsp;kUSB_DeviceClassEventSetEndpointHalt + kUSB_DeviceClassEventClearEndpointHalt.&amp;nbsp;Which will unexpectedly send some content to the host (which at that moment will be in that buffer).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand that probability of such event is very low, especially in the case of a keyboard.&amp;nbsp;But a similar operating principle is used in many classes/examples: phdc, com-port, etc.&amp;nbsp;That's why I came up with idea of ​​using a protection in the form of&amp;nbsp;disable+enable USB interrupts inside main().&lt;/P&gt;</description>
    <pubDate>Sun, 21 Sep 2025 09:40:28 GMT</pubDate>
    <dc:creator>olex</dc:creator>
    <dc:date>2025-09-21T09:40:28Z</dc:date>
    <item>
      <title>Code examples do not take into account "parallel" access from main() and USB ISR.</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2172104#M5328</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Let's take a look at &lt;A href="https://github.com/Masmiseim36/nxpSDK" target="_blank"&gt;https://github.com/Masmiseim36/nxpSDK&lt;/A&gt; samples.&lt;/P&gt;&lt;P&gt;The problem I want to discuss exists across many samples. Let's take evkmimxrt1010/usb_examples/usb_device_composite_hid_audio_unified/bm for specificity.&lt;/P&gt;&lt;P&gt;USB_DeviceHidKeyboardAction() is regularly called from the main() cycle.&lt;BR /&gt;It calls USB_DeviceHidSend() function, which accesses interruptInPipeBusy, interruptInPipeStall, interruptInPipeDataBuffer fields.&lt;BR /&gt;And the same fields can be accessed from under USB IRQ handler (during kUSB_DeviceClassEventClearEndpointHalt, etc operations).&lt;BR /&gt;Which can lead to unintended effects.&lt;/P&gt;&lt;P&gt;How can we get protection from this?&lt;BR /&gt;Would it be a good idea to disable USB interrupts in USB_DeviceHidKeyboardAction() function before calling USB_DeviceHidSend() and enable them afterwards? Will there be any problems because deep within USB_DeviceHidSend() function there are DisableGlobalIRQ + EnableGlobalIRQ operations being performed?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Sep 2025 15:07:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2172104#M5328</guid>
      <dc:creator>olex</dc:creator>
      <dc:date>2025-09-18T15:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: Code examples do not take into account "parallel" access from main() and USB ISR.</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2172891#M5333</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/254985"&gt;@olex&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Firstly, the oficial distribution of NXP's SDK is via the following GitHub repository:&amp;nbsp;&lt;A href="https://github.com/nxp-mcuxpresso/mcuxsdk-manifests" target="_blank"&gt;GitHub - nxp-mcuxpresso/mcuxsdk-manifests: Manifest repo for MCUXpresso SDK project&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Or the following SDK builder page:&amp;nbsp;&lt;A href="https://mcuxpresso.nxp.com/select" target="_blank"&gt;Select Board | MCUXpresso SDK Builder&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Secondly, I'm not quite sure I understand why the access of&amp;nbsp;&lt;SPAN&gt;interruptInPipeBusy, interruptInPipeStall, interruptInPipeDataBuffer fields on the&amp;nbsp;USB_DeviceHidSend() function as well as the USB IRQ handler would lead uninteded consequences.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Could you please elaborate on this?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;BR,&lt;BR /&gt;Edwin.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Sep 2025 16:47:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2172891#M5333</guid>
      <dc:creator>EdwinHz</dc:creator>
      <dc:date>2025-09-19T16:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Code examples do not take into account "parallel" access from main() and USB ISR.</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2173118#M5335</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi Edwin,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;First of all, I would like to apologize for indicating an unofficial repository. When I was just getting started with NXP-chips, a friend recommended setting up MCUXpresso IDE exactly with it. I had no idea it was an unofficial repository:(&lt;/P&gt;&lt;P&gt;In the official repository I don't see interruptInPipeStall and interruptInPipeDataBuffer fields, in the use of which I noticed a problem. So, I don't know if it makes sense to continue the discussion:)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following code is executed in the main() context:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;usb_status_t USB_DeviceHidSend( class_handle_t handle, uint8_t ep, uint8_t* buffer, uint32_t length )
{
	usb_device_hid_struct_t* hidHandle;
	usb_status_t error = kStatus_USB_Error;

	if ( NULL == handle )
		return kStatus_USB_InvalidHandle;

	hidHandle = (usb_device_hid_struct_t*)handle;

	if ( 0U != hidHandle-&amp;gt;interruptInPipeBusy )
		return kStatus_USB_Busy;

	hidHandle-&amp;gt;interruptInPipeBusy = 1U;

	if ( 0U != hidHandle-&amp;gt;interruptInPipeStall )
	{
		hidHandle-&amp;gt;interruptInPipeDataBuffer = buffer;
		hidHandle-&amp;gt;interruptInPipeDataLen = length;
		return kStatus_USB_Success;
	}

	error = USB_DeviceSendRequest( hidHandle-&amp;gt;handle, ep, buffer, length );
	if ( kStatus_USB_Success != error )
		hidHandle-&amp;gt;interruptInPipeBusy = 0U;

	return error;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And the following code is executed under USB-ISR:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;case kUSB_DeviceClassEventSetEndpointHalt:
	if ( ( NULL == hidHandle-&amp;gt;configStruct ) || ( NULL == hidHandle-&amp;gt;interfaceHandle ) )
		break;
	/* Get the endpoint address */
	temp8 = ( (uint8_t*)param );
	for ( count = 0U; count &amp;lt; hidHandle-&amp;gt;interfaceHandle-&amp;gt;endpointList.count; count++ )
	{
		if ( *temp8 == hidHandle-&amp;gt;interfaceHandle-&amp;gt;endpointList.endpoint[count].endpointAddress )
		{
			/* Only stall the endpoint belongs to the class */
			if ( USB_IN == ( ( hidHandle-&amp;gt;interfaceHandle-&amp;gt;endpointList.endpoint[count].endpointAddress &amp;amp; USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK ) &amp;gt;&amp;gt; USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT ) )
				hidHandle-&amp;gt;interruptInPipeStall = 1U;
			else
				hidHandle-&amp;gt;interruptOutPipeStall = 1U;
			error = USB_DeviceStallEndpoint( hidHandle-&amp;gt;handle, *temp8 );
		}
	}
	break;
case kUSB_DeviceClassEventClearEndpointHalt:
	if ( ( NULL == hidHandle-&amp;gt;configStruct ) || ( NULL == hidHandle-&amp;gt;interfaceHandle ) )
		break;
	/* Get the endpoint address */
	temp8 = ( (uint8_t*)param );
	for ( count = 0U; count &amp;lt; hidHandle-&amp;gt;interfaceHandle-&amp;gt;endpointList.count; count++ )
	{
		if ( *temp8 == hidHandle-&amp;gt;interfaceHandle-&amp;gt;endpointList.endpoint[count].endpointAddress )
		{
			/* Only un-stall the endpoint belongs to the class */
			error = USB_DeviceUnstallEndpoint( hidHandle-&amp;gt;handle, *temp8 );
			if ( USB_IN == ( ( ( *temp8 ) &amp;amp; USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK ) &amp;gt;&amp;gt;
				USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT ) )
			{
				if ( 0U != hidHandle-&amp;gt;interruptInPipeStall )
				{
					hidHandle-&amp;gt;interruptInPipeStall = 0U;
					if ( (uint8_t*)USB_INVALID_TRANSFER_BUFFER != hidHandle-&amp;gt;interruptInPipeDataBuffer )
					{
						error = USB_DeviceSendRequest( hidHandle-&amp;gt;handle, ( hidHandle-&amp;gt;interfaceHandle-&amp;gt;endpointList.endpoint[count].endpointAddress &amp;amp; USB_DESCRIPTOR_ENDPOINT_ADDRESS_NUMBER_MASK ), hidHandle-&amp;gt;interruptInPipeDataBuffer, hidHandle-&amp;gt;interruptInPipeDataLen );
						if ( kStatus_USB_Success != error )
						{
							usb_device_endpoint_callback_message_struct_t endpointCallbackMessage;
							endpointCallbackMessage.buffer = hidHandle-&amp;gt;interruptInPipeDataBuffer;
							endpointCallbackMessage.length = hidHandle-&amp;gt;interruptInPipeDataLen;
							endpointCallbackMessage.isSetup = 0U;
							USB_DeviceHidInterruptIn( hidHandle-&amp;gt;handle, (void*)&amp;amp;endpointCallbackMessage, handle );
						}
						hidHandle-&amp;gt;interruptInPipeDataBuffer = (uint8_t*)USB_INVALID_TRANSFER_BUFFER;
						hidHandle-&amp;gt;interruptInPipeDataLen = 0U;
					}
				}
			}
			else
			{
				if ( 0U != hidHandle-&amp;gt;interruptOutPipeStall )
				{
					hidHandle-&amp;gt;interruptOutPipeStall = 0U;
					if ( (uint8_t*)USB_INVALID_TRANSFER_BUFFER != hidHandle-&amp;gt;interruptOutPipeDataBuffer )
					{
						error = USB_DeviceRecvRequest( hidHandle-&amp;gt;handle, ( hidHandle-&amp;gt;interfaceHandle-&amp;gt;endpointList.endpoint[count].endpointAddress &amp;amp; USB_DESCRIPTOR_ENDPOINT_ADDRESS_NUMBER_MASK ), hidHandle-&amp;gt;interruptOutPipeDataBuffer, hidHandle-&amp;gt;interruptOutPipeDataLen );
						if ( kStatus_USB_Success != error )
						{
							usb_device_endpoint_callback_message_struct_t endpointCallbackMessage;
							endpointCallbackMessage.buffer = hidHandle-&amp;gt;interruptOutPipeDataBuffer;
							endpointCallbackMessage.length = hidHandle-&amp;gt;interruptOutPipeDataLen;
							endpointCallbackMessage.isSetup = 0U;
							USB_DeviceHidInterruptOut( hidHandle-&amp;gt;handle, (void*)&amp;amp;endpointCallbackMessage, handle );
						}
						hidHandle-&amp;gt;interruptOutPipeDataBuffer = (uint8_t*)USB_INVALID_TRANSFER_BUFFER;
						hidHandle-&amp;gt;interruptOutPipeDataLen = 0U;
					}
				}
			}
		}
	}
	break;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If during main() execution an interrupt is triggered at this point:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="olex_0-1758445645075.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/357837i2CE3D10084BA9D27/image-size/medium?v=v2&amp;amp;px=400" role="button" title="olex_0-1758445645075.png" alt="olex_0-1758445645075.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;olex_0-1758445645075.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;, and this interrupt handles kUSB_DeviceClassEventClearEndpointHalt event, then the pointer to a some buffer will be saved in interruptInPipeDataBuffer and interruptInPipeDataLen fields.&lt;/P&gt;&lt;P&gt;And this information will be "hidden/waiting" until the next pair of events&amp;nbsp;kUSB_DeviceClassEventSetEndpointHalt + kUSB_DeviceClassEventClearEndpointHalt.&amp;nbsp;Which will unexpectedly send some content to the host (which at that moment will be in that buffer).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand that probability of such event is very low, especially in the case of a keyboard.&amp;nbsp;But a similar operating principle is used in many classes/examples: phdc, com-port, etc.&amp;nbsp;That's why I came up with idea of ​​using a protection in the form of&amp;nbsp;disable+enable USB interrupts inside main().&lt;/P&gt;</description>
      <pubDate>Sun, 21 Sep 2025 09:40:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2173118#M5335</guid>
      <dc:creator>olex</dc:creator>
      <dc:date>2025-09-21T09:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Code examples do not take into account "parallel" access from main() and USB ISR.</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2173682#M5339</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/254985"&gt;@olex&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Thank you for the clarifications. I highly recommend you use the official NXP SDK repository as a base for the USB driver on our devices, especially if the issue you mention with the&lt;SPAN&gt;&amp;nbsp;interruptInPipeStall and interruptInPipeDataBuffer fields is not present in it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It's still good to have this post describe the possibility of the problem you mention in case someone in the future stumbles upon the same situation as you did.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks for reporting this.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;BR,&lt;BR /&gt;Edwin.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Sep 2025 17:17:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2173682#M5339</guid>
      <dc:creator>EdwinHz</dc:creator>
      <dc:date>2025-09-22T17:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: Code examples do not take into account "parallel" access from main() and USB ISR.</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2178191#M5350</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;Edwin,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have updated information.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;SDK version 25.06. Downloaded via MCUXpresso IDE v25.6 or directly from SDK Builder web-site.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Let's take EVK-MIMXRT1010 board, usb_device_composite_hid_audio_unified_bm example.&lt;/P&gt;&lt;P&gt;Official SDK also has an issue with interruptInPipeStall field and similar ones, which I described earlier.&lt;/P&gt;&lt;P&gt;Therefore, my question still stands.&lt;/P&gt;&lt;P&gt;Would it be a good idea to call DisableIRQ( UsbIrqNumber ) in USB_DeviceHidKeyboardAction() function before calling USB_DeviceHidSend() and enable it afterwards? Will there be any problems because deep within USB_DeviceHidSend() function there are DisableGlobalIRQ + EnableGlobalIRQ operations being performed?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Sep 2025 12:03:20 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2178191#M5350</guid>
      <dc:creator>olex</dc:creator>
      <dc:date>2025-09-30T12:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Code examples do not take into account "parallel" access from main() and USB ISR.</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2178428#M5351</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/254985"&gt;@olex&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Thanks for the update.&lt;/P&gt;
&lt;P&gt;Normally we wouldn't recommend changing the device drivers like that. Could you describe a situation where the problem you describe might appear? I'm not completely sure I understand where the issue lies on the USB drivers.&lt;/P&gt;
&lt;P&gt;Thanks for the clarifications.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Sep 2025 21:32:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2178428#M5351</guid>
      <dc:creator>EdwinHz</dc:creator>
      <dc:date>2025-09-30T21:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Code examples do not take into account "parallel" access from main() and USB ISR.</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2178700#M5353</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;Edwin,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Below is an excerpt from USB_DeviceHidSend() function implementation:&lt;/SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="olex_0-1759312418535.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/359149i778E189BFEDBE7DD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="olex_0-1759312418535.png" alt="olex_0-1759312418535.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;olex_0-1759312418535.png&lt;/span&gt;&lt;/span&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;main() cycle periodically calls USB_DeviceHidSend()&lt;BR /&gt;and USB ISR also calls USB_DeviceHidSend() periodically&lt;/P&gt;&lt;P&gt;USB ISR can occur/intervene at any arbitrary point in main() execution, including the point between checking busy-flag and setting it to 1.&lt;BR /&gt;As a result, we will get an inconsistent "parallel" code execution.&lt;/P&gt;&lt;P&gt;And SDK middleware has many functions similar to USB_DeviceHidSend() described. The same applies to example applications.&lt;/P&gt;&lt;P&gt;My proposal is not to change the drivers code, but to change the way the driver functions are used in the application.&lt;BR /&gt;I want to disable USB interrupts during USB_DeviceHidSend() is called from the context of main().&lt;/P&gt;&lt;P&gt;Is this a normal idea?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Oct 2025 09:58:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2178700#M5353</guid>
      <dc:creator>olex</dc:creator>
      <dc:date>2025-10-01T09:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Code examples do not take into account "parallel" access from main() and USB ISR.</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2178943#M5355</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/254985"&gt;@olex&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Thanks for the explanation, I understand.&lt;/P&gt;
&lt;P&gt;I hypothesize that your modification would be useful for the mentioned cases where a USB ISR can occur during main() execution.&lt;/P&gt;
&lt;P&gt;I don't think it will cause any unwanted behavior but rather will add robustness to the application.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Oct 2025 18:20:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2178943#M5355</guid>
      <dc:creator>EdwinHz</dc:creator>
      <dc:date>2025-10-01T18:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Code examples do not take into account "parallel" access from main() and USB ISR.</title>
      <link>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2179151#M5356</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thank you, Edwin!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Oct 2025 06:55:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCUXpresso-SDK/Code-examples-do-not-take-into-account-quot-parallel-quot-access/m-p/2179151#M5356</guid>
      <dc:creator>olex</dc:creator>
      <dc:date>2025-10-02T06:55:21Z</dc:date>
    </item>
  </channel>
</rss>

