Difference between revisions of "PIC32MX: RS232"
Andrew Long (talk | contribs) |
Andrew Long (talk | contribs) |
||
Line 10: | Line 10: | ||
=PIC to PC= |
=PIC to PC= |
||
[[Image:usb-rs232-cable.jpg|right]] |
|||
To communicate PIC to PC, you need to have a COMM port or a USB to RS232 converter. You can read about the TTL-232R cable (USB to RS232 converter) [[PIC RS232#FTDIChip TTL-232R USB to RS232 Cable |here]]. |
To communicate PIC to PC, you need to have a COMM port or a USB to RS232 converter. You can read about the TTL-232R cable (USB to RS232 converter) [[PIC RS232#FTDIChip TTL-232R USB to RS232 Cable |here]]. |
||
Line 23: | Line 23: | ||
Note that the TTL-232R cable gives you access to the PC's +5 supply (Red wire), which is limited in current (probably to 500mA) by the USB port which is designed to protect from short circuits. If you wish, you can probably power your PIC from the PC, using USB as a power source. If you do that, get rid of any other +5 source. <b>Don't</b> connect two +5 sources at once. In contrast, be sure that you <b>do</b> connect the PIC's ground to the PC's ground (Black wire). |
Note that the TTL-232R cable gives you access to the PC's +5 supply (Red wire), which is limited in current (probably to 500mA) by the USB port which is designed to protect from short circuits. If you wish, you can probably power your PIC from the PC, using USB as a power source. If you do that, get rid of any other +5 source. <b>Don't</b> connect two +5 sources at once. In contrast, be sure that you <b>do</b> connect the PIC's ground to the PC's ground (Black wire). |
||
Make the following connections for PIC to PC communication (not using CTS or RTS): |
|||
*PC Transmit -- PIC Receive |
|||
*PC Receive -- PIC Transmit |
|||
<br clear=all> |
|||
=Basic Sample Code= |
|||
This code details how to echo typing in a terminal such as Hyper Terminal. The PIC reads the pressed key from the PC and then transmits the key back to the PC via the TTL-232R cable. The key will be displayed on the terminal. |
Revision as of 15:12, 26 August 2009
RS232 is a method of real time communication between two devices such as PIC to PIC or PIC to PC.
More information about RS232 can be found here.
The PIC32 has 2 sets of pins UART1 and UART2. The pins are:
- UxCTS - clear to send (input to PIC)
- UxRTS - ready to send (output from PIC)
- UxRX - PIC receive
- UxTX - PIC transmit
PIC to PC
To communicate PIC to PC, you need to have a COMM port or a USB to RS232 converter. You can read about the TTL-232R cable (USB to RS232 converter) here.
The TTL-232R cable has six wires, color coded and in this sequence on the SIP connector:
BLACK GROUND Connect to PIC ground. BROWN CTS# Unused. "Clear to send" (flow control). RED Vcc +5V from PC. !! DO NOT CONNECT TO PIC +5 !! ORANGE Tx "PC Transmit." Data from PC, to PIC Rx (pin 26). YELLOW Rx "PC Receive." Data from PIC Tx (pin 25), to PC. GREEN RTS# Unused. "Request to send" (flow control).
Note that the TTL-232R cable gives you access to the PC's +5 supply (Red wire), which is limited in current (probably to 500mA) by the USB port which is designed to protect from short circuits. If you wish, you can probably power your PIC from the PC, using USB as a power source. If you do that, get rid of any other +5 source. Don't connect two +5 sources at once. In contrast, be sure that you do connect the PIC's ground to the PC's ground (Black wire).
Make the following connections for PIC to PC communication (not using CTS or RTS):
- PC Transmit -- PIC Receive
- PC Receive -- PIC Transmit
Basic Sample Code
This code details how to echo typing in a terminal such as Hyper Terminal. The PIC reads the pressed key from the PC and then transmits the key back to the PC via the TTL-232R cable. The key will be displayed on the terminal.