void main() {
int count;
char buff[64];
CMCON = 7; // Disable Comparators
UART1_Init(9600); // Baud Rate 9600
Delay_ms(100);
TRISA = 0;
TRISB = 0;
count = 0;
while(1) {
// every some time send the string
if(count >= 255) {
UART1_Write_Text(" UART Test Successful! "); // Character Message to be Sent
UART1_Write(10); // Line Feed
UART1_Write(13); // Carriage Return
count = 0;
PORTA ^= 0x7;
}
// if something is received
if(UART1_Data_Ready())
{
// read and reply
int r = UART1_Read();
buff[0] = r;
buff[1] = 0;
UART1_Write_Text("Letter: ");
UART1_Write_Text(buff);
UART1_Write(10); // Line Feed
UART1_Write(13); // Carriage Return
count = 0;
}
count++;
delay_ms(1);
}
}