td micro
Member level 5
hi,
i tried one simple communication process USART and pic 18f in c18.but when i input something through key board, i m not getting any output. ie, reading 2 chars typed from a terminal and trying to print back these 2 chars. But I'm having problems when trying to print back. Here is the code
could you help me please.. How can i read the chars correctly?
and how string?
Thank you!
i tried one simple communication process USART and pic 18f in c18.but when i input something through key board, i m not getting any output. ie, reading 2 chars typed from a terminal and trying to print back these 2 chars. But I'm having problems when trying to print back. Here is the code
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 void main() { char a[2]; int i; OSCCON =0b01100000; TRISCbits.TRISC6 = 0; // set TX (RC6) as output TRISCbits.TRISC7 = 1; // and RX (RC7) as input OpenUSART(USART_TX_INT_OFF & USART_RX_INT_ON & USART_ASYNCH_MODE & USART_EIGHT_BIT & USART_SINGLE_RX & USART_BRGH_HIGH, 51);// baude rate 9.6 putrsUSART( "\n hallooooooo " ); Delay10KTCYx(200); //putrsUSART( "\r\nPlease Enter your Name\n" ); while (1){ // write to the USART putrsUSART("Type 2 chars: "); // while(BusyUSART()); // wait for input while (!DataRdyUSART()); // get 2 chars and put in inputstr getsUSART(a, 2); putrsUSART("\r\nYou typed: "); putsUSART(a); putrsUSART("\r\n"); } }
could you help me please.. How can i read the chars correctly?
and how string?
Thank you!
Last edited by a moderator: