I am trying to communicate with PIC32 UART. I am able to transmit any data but getting problem in reading the data. In PIC32 there's a function putsUART2("")
which can transmit any data and there's function getsUART1(5, myBuffer, 123);
. Parameter's for this function are:
1)length: This is the length of the string to be received
2)buffer: This is the pointer to the location where the data
received have to be stored.
3)uart_data_wait: This is the time-out count for which the module
has to wait before return. If the time-out count is ‘N’,
the actual time out would be about (19 * N – 1) instruction cycles.
Now what I am doing in my code is
if((U2STAbits.URXDA)!=0) //if data received,then
{
getsUART2(5,RxBuffer , 123); //storing the data in RxBuffer
putsUART2(">>Data Received\r\n");
U2STAbits.URXDA = 0;
U2STAbits.OERR = 0;
putsUART2(RxBuffer); //transmitting the data back to the terminal
}
Now when I type 'A', >>Data Received
is printed on the terminal and I am getting back data in terminal. but as the size of the RxBuffer
is 5
, it only stores one character. Can anyone help me with this, I really want to type a string and get back it on terminal.
Please help, thanks.