Coneccting a pic16f876 and a pic18f4550 with our PC

10/09/2013 18:57

Righ now, we are going to connect in two differents ways, two pics,  pic16f876 and a pic18f4550 with our PC.

In the first circuit (pic16f876), we don´t use the interrupts, but in the other one, we do it. In both cases we have to use the "Virtual serial port driver" sowftware, to create two virtual ports.

The windows´ hyperterminal let us send and recibe data from serial ports in the two circuits.

First project (pic16f876):

We get the communication using the COMPING tool, virtual ports and a rs232 line. This circuit doesn´t use interruptions. 

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
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
  }
}

 

Second project (pic18f4550):

We get the communication using the COMPING tool, virtual ports, interruptions and a rs232 line.

When we send a data from the hyperterminal, the pic ask whith Recibido= (sent data)

#include <18f4550.h>
#FUSES XT,NOWDT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=pin_c6, rcv=pin_c7, bits=8, parity=N)
#include
char ch;
#int_rda
void serial_isr()
{
ch=getchar();
printf("Recibido= %c", ch);
}
void main()
{
lcd_init();
enable_interrupts(global);
enable_interrupts(int_rda);
 while(1) {
 printf(lcd_putc,"\n\r Valor %c", ch);
 delay_ms(800);
 }
}