Comunicacion Serial Rs232 Pic Ccs

Posted on  by 

This article shows how to get started with PIC18F4550 microcontroller USART module using CCS PIC C compiler.
PIC18F4550 microcontroller has one (1) USART (Universal Synchronous/Asynchronous Receive/Transmit) module. This module can work in USRT mode or UART mode. In this topic we are going to use the USART module as UART (Universal Asynchronous Receive/Transmit) to transmit and receive data between the microcontroller and the computer.

Using Multiple RS-232 Ports on a PIC ® MCU or PIC ® DSC. In order to use multiple RS-232 connections on a PIC ® MCU or PIC ® DSC, multiple #USE RS232 pre-processor directives will need to be setup using the STREAM option. A #USE RS232 pre-processor directive will remain in effect for GETC, PUTC, PRINTF and KBHIT functions until another #USE. The next step is setting up the PIC chip. For some reason, I can’t get results that make any sense out of the PIC. Here’s my code written with the CCS C compiler for the midrange PIC devices: // PIC code #include #fuses INTRCIO, NOWDT, NOBROWNOUT, PUT, NOMCLR #use delay (clock=4000000) #use rs232 (baud=9600, xmit=PINC1, rcv=PIN.

PIC18F4550 UART connection circuit schematic:
Pin RC6 (TX) and pin RC7 (RX) are used for the UART (serial) communication between the microcontroller and the computer. To change between TTL logic levels (5V) and RS232 signals (+/-12V), an IC is needed which is max232.
Don’t connect TX and RX pins directly to an RS232 serial port which may damage your microcontroller.
In this example the PIC18F4550 microcontroller uses its internal oscillator and MCLR pin function is disabled.

PIC18F4550 UART example CCS C code:
This is the full C code of this example.