Connecting two pic16f876 by means of rs232
This little proyect shows how comunicates two pic using an rs232 connection.
The first pic, write a number in the rs232 line, as the same time it dispalys it on a lcd display. The second one, get the numbre from the rs232 and displays it on the other lcd.
This circuit doesn´t use interruptions.
Writter pic code:
#include <16f876.h>
#FUSES XT,PUT,NOWDT
#use delay(clock=4000000)
#use rs232(BAUD=9600, BITS=8,PARITY=N, XMIT=PIN_C6,RCV=PIN_C7)
#include <LCD.C>
void main()
{
int numero;
lcd_init();
while(TRUE){
for (numero=0;numero<=10;numero++)
{
printf("%2d",numero);
printf(lcd_putc,"\ftransmitiendo=%2d",numero);
delay_ms(600);
}
//TODO: User Code
}
}
Listener pic code:
#include <picrec.h>
#FUSES XT,PUT,NOWDT
#use delay(clock=4000000)
#use rs232(BAUD=9600, BITS=8,PARITY=N, XMIT=PIN_C6,RCV=PIN_C7)
#include <LCD.c>
#int_RDA
char recibido;
void main()
{
lcd_init();
while (TRUE)
{
lcd_gotoxy(1,1);
printf(lcd_putc,"\frecibiendo=%2c",recibido);
recibido=getc();
}
//TODO: User Code
}