<?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>LPC Microcontrollers中的主题 Re: UART - Virtual COM bridge causes a system freeze</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/UART-Virtual-COM-bridge-causes-a-system-freeze/m-p/1316500#M46038</link>
    <description>&lt;P&gt;I found the problem.&lt;/P&gt;&lt;P&gt;seems that&amp;nbsp;&amp;nbsp;&lt;EM&gt;kUSART_RxErrorInterruptEnable flag&amp;nbsp;&lt;/EM&gt;caused it.&lt;/P&gt;&lt;P&gt;The bridge works fine without the flag.&lt;/P&gt;</description>
    <pubDate>Mon, 02 Aug 2021 07:16:30 GMT</pubDate>
    <dc:creator>embedded_eng_</dc:creator>
    <dc:date>2021-08-02T07:16:30Z</dc:date>
    <item>
      <title>UART - Virtual COM bridge causes a system freeze</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/UART-Virtual-COM-bridge-causes-a-system-freeze/m-p/1316267#M46031</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I changed the&amp;nbsp;lpcxpresso55s16_dev_composite_cdc_msc_bm example to bridge the virtual com with UART (Flexcomm 1).&lt;/P&gt;&lt;P&gt;The UART part is based on interrupts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;UART to virtual COM:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;UART init:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#define FLEXCOMM1_PERIPHERAL            USART1
#define FLEXCOMM1_CLOCK_SOURCE    12000000UL
#define FLEXCOMM1_FLEXCOMM_IRQN FLEXCOMM1_IRQn
#define FLEXCOMM1_FLEXCOMM_IRQHANDLER       FLEXCOMM1_IRQHandler



	usart_config_t config;
	USART_GetDefaultConfig(&amp;amp;config);
	config.baudRate_Bps = BOARD_DEBUG_UART_BAUDRATE;
	config.enableTx     = true;
	config.enableRx     = true;
	USART_Init(FLEXCOMM1_PERIPHERAL, &amp;amp;config, FLEXCOMM1_CLOCK_SOURCE);
	USART_EnableInterrupts(FLEXCOMM1_PERIPHERAL, kUSART_RxLevelInterruptEnable | kUSART_RxErrorInterruptEnable);
    EnableIRQ(FLEXCOMM1_FLEXCOMM_IRQN);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UART interrupt handler:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;void FLEXCOMM1_IRQHandler(void)
{
    uint8_t data;

    /* If new data arrived. */
    if ((kUSART_RxFifoNotEmptyFlag | kUSART_RxError) &amp;amp; USART_GetStatusFlags(FLEXCOMM1_PERIPHERAL))
    {
        data = USART_ReadByte(FLEXCOMM1_PERIPHERAL);
        send_to_virtual_com(data);
    }
    SDK_ISR_EXIT_BARRIER;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The function that actually send the data to the virtual com:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;void send_to_virtual_com(uint8_t byte) {
	if ((1 == g_deviceComposite-&amp;gt;cdcVcom.attach) &amp;amp;&amp;amp; (1 == g_deviceComposite-&amp;gt;cdcVcom.startTransactions)) {
		uint8_t *buf = &amp;amp;byte;
		USB_DeviceCdcAcmSend(g_deviceComposite-&amp;gt;cdcVcom.cdcAcmHandle, USB_CDC_VCOM_DIC_BULK_IN_ENDPOINT, buf, 1);

	g_deviceComposite-&amp;gt;cdcVcomRecvSize    = 0;
        g_deviceComposite-&amp;gt;cdcVcomSendSize    = 0;

    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Virtual COM to UART:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;The following code is part of the infinite loop in main function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    if ((1 == g_deviceComposite-&amp;gt;cdcVcom.attach) &amp;amp;&amp;amp; (1 == g_deviceComposite-&amp;gt;cdcVcom.startTransactions))
    {
        /* User Code */
        /* endpoint callback length is USB_CANCELLED_TRANSFER_LENGTH (0xFFFFFFFFU) when transfer is canceled */
        if ((0 != g_deviceComposite-&amp;gt;cdcVcomRecvSize) &amp;amp;&amp;amp; (USB_CANCELLED_TRANSFER_LENGTH != g_deviceComposite-&amp;gt;cdcVcomRecvSize))
        {
            int32_t i;

            /* Copy Buffer to Send Buff */
            for (i = 0; i &amp;lt; g_deviceComposite-&amp;gt;cdcVcomRecvSize; i++)
            {
                s_currSendBuf[g_deviceComposite-&amp;gt;cdcVcomSendSize++] = s_currRecvBuf[i];
            }
            g_deviceComposite-&amp;gt;cdcVcomRecvSize = 0;
        }

        if (g_deviceComposite-&amp;gt;cdcVcomSendSize)
        {
            uint32_t size = g_deviceComposite-&amp;gt;cdcVcomSendSize;
            g_deviceComposite-&amp;gt;cdcVcomSendSize    = 0;
            sendToUart(s_currSendBuf);

            if (error != kStatus_USB_Success)
            {
            }
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The function that actually send the data to the UART:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;void sendToUart(uint8_t *buf) {
	USART_WriteBlocking(FLEXCOMM1_PERIPHERAL, buf, (sizeof(buf) / sizeof(buf[0])) - 1);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem I have is that after ~7000 bytes sent from UART to the virtual COM, the whole system freezes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe someone can help?&lt;/P&gt;</description>
      <pubDate>Sun, 01 Aug 2021 15:29:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/UART-Virtual-COM-bridge-causes-a-system-freeze/m-p/1316267#M46031</guid>
      <dc:creator>embedded_eng_</dc:creator>
      <dc:date>2021-08-01T15:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: UART - Virtual COM bridge causes a system freeze</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/UART-Virtual-COM-bridge-causes-a-system-freeze/m-p/1316500#M46038</link>
      <description>&lt;P&gt;I found the problem.&lt;/P&gt;&lt;P&gt;seems that&amp;nbsp;&amp;nbsp;&lt;EM&gt;kUSART_RxErrorInterruptEnable flag&amp;nbsp;&lt;/EM&gt;caused it.&lt;/P&gt;&lt;P&gt;The bridge works fine without the flag.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Aug 2021 07:16:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/UART-Virtual-COM-bridge-causes-a-system-freeze/m-p/1316500#M46038</guid>
      <dc:creator>embedded_eng_</dc:creator>
      <dc:date>2021-08-02T07:16:30Z</dc:date>
    </item>
  </channel>
</rss>

