ss_blog_claim=726e70d7c87c20ae33aa7a61f06eb8aa

Wednesday, August 20, 2008

code snippet for serial communication

Hi here is the code for serial communication using CCS C compiler
// USART TRANSMITION //

//PIN CONFIGURATION: PIN_C6 FOR TRANSMITION & PIN_C7 FOR RECEPTION;
//THIS PROGRAM IS USED TO TRANSMIT DATA FROM CONTROLLER TO HYPERTERMINAL;
//SEE THE FOLLOWING PROGRAM;


#include<16f877a.h> //HEADER FILE;
#use delay(clock=20000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP//CRYSTAL FREGUENCY IS 20MHZ;
#use rs232(baud=9600,xmit=pin_c6,rcv=pin_c7)//TRANSMITION THROUGH RS232 ;
#byte portc=0x07 // SPECIFY PORTC ADDRESS;

main( )
{

set_tris_c(0x80); //SET TX_PIN & CLEAR RC_PIN;

while(1)
{

printf("welcome to"); // IF I=0 DISPLAY "welcome to";
delay_ms(500);

printf("serial communication"); //IF I=1 DISPLAY "serial communication";
delay_ms(500);

}

}

No comments: