cancel
Showing results for 
Search instead for 
Did you mean: 

Virtual Com Port

mvi
Associate II
Posted on November 27, 2008 at 11:13

Virtual Com Port

12 REPLIES 12
wmaguire
Associate II
Posted on May 17, 2011 at 12:34

Thanks Trevor,

I am using the example in the um0424.zip file. Is this the latest? BTW there is a bug in the code I posted for receiving.

this section of code in main.c should be changed from

if (localUSARTCount > 0)

{

spacesLeft = VIRTUAL_COM_PORT_DATA_SIZE - count_in;

if (localUSARTCount <= spacesLeft)

{

for (i=0;i

{

buffer_in[count_in+i] = USART1RxBuffer[USART1RxReadIndex++];

USART1RxReadIndex &= (USART_RX_BUFFER_SIZE-1);

}

count_in += localUSARTCount;

USART_ITConfig(USART1, USART_IT_RXNE, DISABLE);

USART1RxCount -= localUSARTCount;

USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);

while (_GetEPTxStatus(ENDP1)==EP_TX_VALID);

UserToPMABufferCopy(buffer_in, ENDP1_TXADDR, count_in); //intent; send ascii[] to usb packet-memory-area

SetEPTxCount(ENDP1, count_in); //intent; tell usb how many bytes to send

SetEPTxValid(ENDP1); //intent; enable usb tx endpoint for transmission

}

}

TO

if (localUSARTCount > 0)

{

while (_GetEPTxStatus(ENDP1)==EP_TX_VALID);

spacesLeft = VIRTUAL_COM_PORT_DATA_SIZE - count_in;

if (localUSARTCount <= spacesLeft)

{

for (i=0;i

{

buffer_in[count_in+i] = USART1RxBuffer[USART1RxReadIndex++];

USART1RxReadIndex &= (USART_RX_BUFFER_SIZE-1);

}

count_in += localUSARTCount;

USART_ITConfig(USART1, USART_IT_RXNE, DISABLE);

USART1RxCount -= localUSARTCount;

USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);

UserToPMABufferCopy(buffer_in, ENDP1_TXADDR, count_in); //intent; send ascii[] to usb packet-memory-area

SetEPTxCount(ENDP1, count_in); //intent; tell usb how many bytes to send

SetEPTxValid(ENDP1); //intent; enable usb tx endpoint for transmission

}

}

Otherwise you can overwrite buffer_in before the USB send is complete.

Regards

Walt

:)

trevor1
Associate II
Posted on May 17, 2011 at 12:34

Or use a ''proper'' terminal. Just my opinion but HyperTerminal has many issues which is why I stopped using it many years ago. I use TeraTerm which is much more advanced, can be scripted and is free (and open source). There are of course many other good terminals also.

janus
Associate
Posted on February 27, 2012 at 20:01

ST Vcom library example / tutorial for Mini STM 32 in Keil

Here is what I did for Vcom in Keil, please see attached file.

I wanted very simple but working code.

I hope this will be useful to someone, sorry for any mistakes or errors.

________________

Attachments :

ForMiniSTM32.doc.pdf : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtZR&d=%2Fa%2F0X0000000aRq%2FleGZaEKsFYg3sIwm2s9U7VFU8n3LEuCsw7_Kb1CroYs&asPdf=false