Demonstrates sending and receiving data between Primer and PC virtual (USB)COM port. Has the following advantage;-
- No extra hardware needed to convert UART logic levels to RS232 or other levels. Just connect STM32 USB port to a USB socket on your PC. An extra (virtual) COM* port will become available*.
- Windows software that uses the standard serial com port API can access the primer if it chooses to.
- Fast operation without need for DMA buffer to get round lack of FIFO on a normal UART*.
The data sent by the primer is a fixed test pattern. The data received from the PC host is whatever the user sends from it.
The Windows application may access the Virtual com port at 115200 baud, no parity, 8 data bits, 1 stop bit. Works with dumb terminal programs like hyperterminal. Other baud will likely still work just fine .
*Windows XP will invite you to tell it where the driver for the USB device is located when you connect the primer for the first time to the PC while the primer is running USB2COMn application. You should point it to stmcdc.inf provided in the Software Driver folder.
*You can identify the virtual com port number allocated with Windows Device manager. Expand the Ports node.
* An STM32F10x UART has no FIFO so we would allocate precious RAM for DMA, more at high speed. STM32F103 USB with its own buffers is designed from the outset for higher speeds without having to choose between interrupt-overhead versus DMA-RAM-usage.
Interestingly the lack of a FIFO on the UART is not as limiting as it first seems since often received data is put onto a queue in RAM - anyway. You can arrange to manage access to the UARTS receive DMA buffer thru functions that make it look like a simple queue thus skipping the FIFO altogether. These functions; Qsize() and QTakeFromHead() work by monitoring the DMA_CNDTRx register to detect buffer fill level and maintaining a record of the fake queue head. The only constraint is that QTakeFromHead() must be called before the queue overfills to maintain the integrity of the fake Queue.
Tips
a) Start USB2COMn first, second connect USB between PC and STM32, third start the windows ware that accesses the COM port.
b) Close the windows COMx access program first, then disconnect USB, close USB2COMn.
c) Be aware that terminal programs
1) may remove characters like linefeeds from files transferred.
2) are often very slow, especialy at transferring files. A quick way to send a file to the virtual COM port is to use the command line COPY command like this; COPY file COM8:
Origin: Based on PrimerMouse and ST's Virtual_COM_Port project for the STM3210B_EVAL. All credit should go to the authors of those applications.
History;
version 1.1 - Fixed problem with Windows XP recognising the device. Now both recognition and comms are reliable.