Saturday, January 1, 2011

How to Interface PIC16F877A / 18F452 with RS232C Serial Communication Using CCSC

Communication between a Microcontroller and a Computer is not a big thing. Use a level converter in between Microcontroller and PC. You can test it using a proteus simulation  or directly connect your hardware to PC and use Hiper Terminal for Testing

Here a Simple code for testing Serial Communication

        #include <16F877A.h>
        #DEVICE ADC=10
        #fuses HS,NOWDT,NOPROTECT,NOLVP
        #use delay(clock=20000000)
        #use rs232 (baud=9600,rcv=PIN_C7, xmit=PIN_C6)

        int count=0;
       
        void main()
        {
        while(1){

        //1 Sec Delay
        delay_ms(1000);

        //Increment Count
        count ++;
        if (count>60)
      {  count=0;}

        //Send data to PC
        printf("\n\r Count Value: %d",count);
        }
        }

No comments:

Post a Comment