Check this Program correct or not?
#include<pic.h>
__CONFIG(FOSC_HS & WDTE_OFF & PWRTE_ON & MCLRE_OFF & CP_OFF & BOREN_ON & CLKOUTEN_OFF & IESO_ON & FCMEN_ON);
__CONFIG(WRT_OFF & VCAPEN_OFF & LPBOR_OFF & STVREN_OFF & BORV_HI & LVP_OFF);
unsigned int sec,msec,count;
void send_message(unsigned char const *msg);
void main()
{ ;
TRISA = 0xFF; /* Configure RA<0...7> as input */
TRISB = 0xFF; /* Configure RB<0...7> as input */
TRISD = 0x00; /* Configure RD<0...7> as output */
TRISC = 0x80; /* Configure RC0, RC1, RC3, RC4, RC5 and Tx(RC6) as output */
TRISE = 0x00;
TRISF = 0x00;
TRISG = 0x00;
unsigned count;
T5GCON=0x00;
CCPTMRS0=0x00;
CCPTMRS1=0x01;
CCPTMRS2=0x00;
ANSELE=0x00;
ANSELGbits.ANSG4=0;
PORTA=0x00;
PORTC=0x00;
PORTB=0x00;
PORTD=0x00;
PORTE=0x00;
PORTF=0x00;
PORTG=0x00;
//TX1STA=0x24;
//RC1STA=0x90;
//BAUD1CON=0x00;
SPBRG=32;
SP1BRGH = 1; /* high baud rate */
//SPBRG = X; /* set the baud rate */
BAUD1CONbits.BRG16=0;
BAUD1CONbits.ABDOVF=0;
BAUD1CONbits.RCIDL=0;
BAUD1CONbits.SCKP=0;
BAUD1CONbits.WUE=0;
BAUD1CONbits.ABDEN=1;
TX1STAbits.SYNC = 0; //TX1STAbits.SYNC = 0; /* asynchronous */
TX1STAbits.SENDB= 0;
RC1STAbits.SPEN = 1; /* enable serial port pins */
RC1STAbits.CREN = 1; /* enable reception */
RC1STAbits.SREN = 0; /* no effect */
PIE1bits.TX1IE = 0; /* disable tx interrupts */
PIE1bits.RC1IE = 0; /* disable rx interrupts */
TX1STAbits.TX9 = 0; /* 8- or 9-bit transmission */
RC1STAbits.RX9 = 0; /* 8- or 9-bit reception */
TX1STAbits.TXEN = 1; /* enable the transmitter */
GIE=PEIE=TMR2IE=1;
T2CON=0x07;
TMR2=193;
send_message("Hai kct");
send_message("\r\n");
while(1)
{
//if(sec>10)
// {
sec=0;
send_message("serial port checking");
send_message("\r\n");
LATC3=0xFF;
for(count=0;count<50000;count++);
for(count=0;count<50000;count++);
LATC3 =0x00;
for(count=0;count<50000;count++);
for(count=0;count<50000;count++);
// }
}
}
void send_message(unsigned char const *msg)
{
while(*msg!='\0')
{
TX1REG=*msg;
while(!TX1STAbits.TRMT);
msg++;
}
}