void InitU1(void){
U1MODEbits.BRGH = 0;
U1BRG =12;
U1MODE =0x8070;
RPINR18 = 0x000E;
U1STA = 0x5400;
TRISBbits.TRISB1 = 1; // enable RTS , output
RPINR18bits.U1CTSR = 6; //set CTS pin RP6
//RPINR18bits.U1RXR = 14; //set RX pin RP8
RPOR0bits.RP1R = 3; //set TX pin RP1
RPOR1bits.RP3R = 4; //set RTS pin RP3
}
char getU1 (void)
{
//RTS = 0; // telling the other side !RTS
//while (!U1STAbits.URXDA ); // wait
//RTS =1; // telling the other side RTS
return U1RXREG ; // from receiving buffer
}
int main(void) {
LCD_Initialize();
InitU1();
int i=0;
char readRX;
char rx[15];
ms_delay(120);
readRX = getU1();
ms_delay(2);
printf("Value of readRX %c\n", readRX);
ms_delay(100);
while(i<14){
for (i=0; i<15; i++){
rx[I] = getU1();[/I]
[I]ms_delay(1);
}
}[/I]
[I]printf("\f");
printf("RX input: %s\n", rx);[/I]
[I]ms_delay(100);[/I]
[I]}