Buy(Cart) Contact NSDSP Home

NSDSP UART-to-USB Interface

In UART mode, NSDSP streams full duplex data between USB and an UART device connected to its RX/TX pins.

NSDSP cannot be in UART mode and Debug mode at the same time. Therefore, UART interface is unavailable during debugging. However, while you debug through NSDSP, you can use another NSDSP to provide UART connectivity.

UART connection

NSDSP's RX pin must be connected to PIC's TX pin and NSDSP's TX pin must be cooonected to PIC's RX pin. If you use flow control, RTS/CTS pins must be connected too. For more details, see connections.

PIC can also use PGC/PGD pins. They may be configured to change state when a USB connection is establisahed or lost and when NSDSP enters UART mode.

USB Transmission

NSDSP is a USB HID device. Therefore, information between NSDSP and host computer is exchanged by packets of fixed size.

The connection is full-duplex. Data transfers from the PIC to the host computer occur simultaneously and independetly from data transfers from the host computer to the PIC.

PIC to Host

The packets transmitted from NSDSP to the host computer are 64 byte long. Only 62 bytes are usable. Packets are sent every millisecond. Therefore, the maximum achievable transfer rate is 60.5 KBytes per second.

Communication software on the host computer continuously receives packets from NSDSP and buffers them. There is no mechanism to pause the transmission from the host side. Therefore, a large buffer is used by the software. Typically, the size of the buffer is 256K, which is enough to store 4 seconds of data received from PIC even at the highest speed. To prevent buffer overflow, the data must be read at least once every 4 seconds.

Host to PIC

The packets transmitted from the host computer to NSDSP are 1024 byte long. Only 1008 bytes are usable. It takes 16ms to transfer the packet to NSDSP. Therefore, the maximum achievable transfer rate is 61.5 KBytes per second. On some computers with older operating systems or slower processors, there could be an extra 1ms delay between packets. Therefore, the maximum transmission may fall to 58 KBytes per second.

Even if you want to transfer a single byte, the whole packet must be transferred. NSDSP starts processing the data as soon as the transmission of the packet begins, but afterwards the system has to wait for the rest of the packet to be transmitted. Therefore, the next packet may be delayed up to 16ms. Typically, this is not a problem because the communication software on the host computer buffers and packetizes the data as dense as possible. However, if your communication protocol involves sending small data pieces back and forth, this may increase the latency and slow down the transmission.

Flow control

A flow control may be necessary in one of the cases:

  • Baud rate is above 500K
  • USB line is of low quality
  • PIC cannot receive data as fast as NSDSP sends them

CTS and RTS pins are used for flow control.

If flow control is used then NSDSP samples its CTS pin before sending a byte to PIC. NSDSP sends a byte to PIC only if CTS is low. To be compatible with hardware flow control implementation on PIC UART modules, NSDSP samples the CTS pin very late - only after the transmission of previous byte has ended. This introduces a two-baud delay between bytes being sent to PIC and reduces transmission rate by 20 percent. Such delay is not needed when flow control is off.

When NSDSP is running out of buffer space while receiving data from PIC, it drives its RTS pin high. Once this happens, PIC has to pause sending until RTS pin is set low. NSDSP still has space for 3 extra symbols. Therefore, PIC can send up to 3 symbols after RTS pin is driven high. Once paused, PIC is supposed to resume transmission as soon as NSDSP drives RTS low.

When flow control is enabled the peak transmission speed slightly decreases.

Flow control must be requested by host software when entering UART mode. Otherwise, RTS pin is kept low and CTS pin is ignored.

NSDSP does not support software (XON/XOFF) flow control.

Baud rates

NSDSP can operate on a number of fixed baud rates listed below. The baud rate is specified by host software when entering UART mode.

Baud Rate Max Transfer Rate Bytes/sec
No Flow Control Flow Control
Host to PIC PIC to Host Host to PIC PIC to Host
1200120120 100120
2400240240 200240
4800480480 400480
9600960960 800960
1920019201920 16001920
3840038403840 32003840
5760057605760 48005760
11520011K11K 960011K
23040023K23K 19K23K
46080045K45K 38K45K
92160062KN/A 62K57K
250000 (250k)24K24K 20K24K
500000 (500k)49K49K 41K49K
1000000 (1M)62KN/A 62K57K
2000000 (2M)62KN/A 62K57K

At low baud rates, the maximum transmission speed is determined by the communication speed between PIC and NSDSP. At higher baud rates, the speed is limited by USB communications between NSDSP and the host computer.

Software

There are two software options.

You can use nsuart command line utility, which you can download as a part of NSDSP Software Suite.

You can write your own software. The example source code can be downloaded for free and includes clode for Windows, Mac, and Linux.

Northern Software Home NSDSP Contact Us Purchase/Vew Cart

© 2007-2023 Northern Software Inc. All Rights Reserved.