Comunicacion Serial Rs232 Pic Ccs
This is a small example shows how to use PIC16F877A UART module using CCS PIC C compiler.
PIC16F877A 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.
CCS C compiler serial monitor can be used to communicate with the microcontroller.
PIC16F877A UART example CCS C code:
This is the full C code for this example.
PIC serial communication tutorial. RS232 uses voltages below (-5V)to represent a logical level '1', and voltages above (5V)to represent a logical level '0'. Therefore, to use this protocol we need voltage level conversion. This is possible using the device such as the MAX232. RS232 communication with CCS C compiler. The CCS C compiler provides a very simple way to do serial communication via RS232. It hides all the register settings for the user. Only the some parameters have to be provided, the rest is done by the compiler. See full list on picprojects.net.
2 4 6 8 10 12 14 16 18 20 22 24 | #fuses HS,NOWDT,NOPROTECT,NOLVP #use rs232(uart1, baud = 9600) // Initialize UART module chari; putc(13);// Go to first column delay_ms(5000);// Wait 5 seconds putc(10);// Start a new line putc(13);// Go to first column while(TRUE){ i=getc();// UART read } } |
Hola Sergio, una preguna, he hecho la cominucacion rs232 con un pic 18f4550, la comunicacion se hace perfectamente, solo tengo un inconveniente, he puesto un texto para que cuando haga la comunicacion aparezca el texto como instructivo de que teclas controlan el circuito, pero cuando hago la comunicacion el texto no aparece, solo aparecen.
PIC16F877A UART example video:
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 RS232 is encountered.
The following example program shows how to read from one RS-232 port (A) and echo the data to both the first RS-232 port (A) and a second RS-232 port (B) without using the STREAM option for #USE RS232:
The following example program will perform the same operations as the one above. The STREAM option in the #USE RS232 pre-processor directive makes the code more readable and is therefore recommended method:
Comunicacion Serial Rs232 Pic Ccs 2017
For more information or additional help about using multiple RS-232 ports on a PIC® MCU or PIC® DSC, contact CCS Technical Support.