<?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>Embedded Software and Tools ClinicのトピックSend data through USB as a virtual COM</title>
    <link>https://community.nxp.com/t5/Embedded-Software-and-Tools/Send-data-through-USB-as-a-virtual-COM/m-p/1235724#M170</link>
    <description>&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;I am trying to include a virtual COM through an USB in KEIL uVision5 with the API and functions that KEIL provides.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been improving my code, and now I am at the point to&amp;nbsp;be able to receive characters from the host (PC). My problem now is that I don't understand how the function "USBD_CDCn_ACM_SendData" works.&lt;/P&gt;&lt;P&gt;My purpose is to include the function "USBD_CDC_ACM_WriteData" inside "SendData" function. I know that WriteData is an asynchronous function, but it never interrupts the program.&lt;/P&gt;&lt;P&gt;My code is:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Called when when all data was sent.
void USBD_CDC0_ACM_SendData (int32_t len) {
  // Add code for handling new data send
	int32_t cnt;
	
	cnt = USBD_CDC_ACM_WriteData(0, mantTxBuf, len);
		
	if(cnt&amp;lt;0) {}
		//error	
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;where "mantTxBuf" is my pointer to the transmitter buffer. I am sharing the same buffer with UART and USB, because my intention is that when I use the USB, the UART will be disable and viceversa. I am secure that there are data ready to be sent on my buffer, but this function never interrupts.&lt;/P&gt;&lt;P&gt;I have tried to implement the "WriteData" function inside the function "USBD_CDC0_ACM_DataSent" (&lt;A href="https://www.keil.com/pack/doc/mw/USB/html/group__usbd__cdc_functions__acm__api.html#ga5091a4b29df447b17bc6bbe87b17db96)" target="_blank"&gt;www.keil.com/.../group__usbd__cdc_functions__acm__api.html&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;but it neither interrupts.&lt;/P&gt;&lt;P&gt;I have the following questions about it:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;1. How "USBD_CDCn_ACM_SendData" works?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;2.&amp;nbsp;&lt;/SPAN&gt;Should I implement the asynchronous function to send data ("USBD_CDC_ACM_WriteData") as a independent function?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;3.&amp;nbsp;&lt;/SPAN&gt;Is there another strategy to send data when I have characters in my Tx buff ("mantTxBuff")??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Feb 2021 11:53:16 GMT</pubDate>
    <dc:creator>javierrobledo</dc:creator>
    <dc:date>2021-02-24T11:53:16Z</dc:date>
    <item>
      <title>Send data through USB as a virtual COM</title>
      <link>https://community.nxp.com/t5/Embedded-Software-and-Tools/Send-data-through-USB-as-a-virtual-COM/m-p/1235724#M170</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;I am trying to include a virtual COM through an USB in KEIL uVision5 with the API and functions that KEIL provides.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been improving my code, and now I am at the point to&amp;nbsp;be able to receive characters from the host (PC). My problem now is that I don't understand how the function "USBD_CDCn_ACM_SendData" works.&lt;/P&gt;&lt;P&gt;My purpose is to include the function "USBD_CDC_ACM_WriteData" inside "SendData" function. I know that WriteData is an asynchronous function, but it never interrupts the program.&lt;/P&gt;&lt;P&gt;My code is:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Called when when all data was sent.
void USBD_CDC0_ACM_SendData (int32_t len) {
  // Add code for handling new data send
	int32_t cnt;
	
	cnt = USBD_CDC_ACM_WriteData(0, mantTxBuf, len);
		
	if(cnt&amp;lt;0) {}
		//error	
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;where "mantTxBuf" is my pointer to the transmitter buffer. I am sharing the same buffer with UART and USB, because my intention is that when I use the USB, the UART will be disable and viceversa. I am secure that there are data ready to be sent on my buffer, but this function never interrupts.&lt;/P&gt;&lt;P&gt;I have tried to implement the "WriteData" function inside the function "USBD_CDC0_ACM_DataSent" (&lt;A href="https://www.keil.com/pack/doc/mw/USB/html/group__usbd__cdc_functions__acm__api.html#ga5091a4b29df447b17bc6bbe87b17db96)" target="_blank"&gt;www.keil.com/.../group__usbd__cdc_functions__acm__api.html&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;but it neither interrupts.&lt;/P&gt;&lt;P&gt;I have the following questions about it:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;1. How "USBD_CDCn_ACM_SendData" works?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;2.&amp;nbsp;&lt;/SPAN&gt;Should I implement the asynchronous function to send data ("USBD_CDC_ACM_WriteData") as a independent function?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;3.&amp;nbsp;&lt;/SPAN&gt;Is there another strategy to send data when I have characters in my Tx buff ("mantTxBuff")??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 11:53:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Embedded-Software-and-Tools/Send-data-through-USB-as-a-virtual-COM/m-p/1235724#M170</guid>
      <dc:creator>javierrobledo</dc:creator>
      <dc:date>2021-02-24T11:53:16Z</dc:date>
    </item>
  </channel>
</rss>

