AndroPic
Newbie level 3
- Joined
- Oct 19, 2013
- Messages
- 3
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 21
Hi Guys
I need a help to parse received data from usart. I use PIC16F877A I want to store data that i receive from usart to array. this is my code:
void main()
{
char data[5];
int i;
Usart_Init(9600);
delay_ms(100);
while(1)
{
if(Usart_Data_Ready())
{
for(i=0;i<5;i++)
{
data=Usart_Read();
}
Usart_Write(data[0]); //
Usart_Write(data[1]); //
Usart_Write(data[2]); //check all data
Usart_Write(data[3]); //
Usart_Write(data[4]); //
}
}
}
but I always got wrong data when i execute it. Example when I send 123 from usart terminal in Mikro C, I will get 1111123333. The when I send 12345, also I will get 1111123333. could someone tell how to store data that I received via usart to array
Thanks Before.
I need a help to parse received data from usart. I use PIC16F877A I want to store data that i receive from usart to array. this is my code:
void main()
{
char data[5];
int i;
Usart_Init(9600);
delay_ms(100);
while(1)
{
if(Usart_Data_Ready())
{
for(i=0;i<5;i++)
{
data=Usart_Read();
}
Usart_Write(data[0]); //
Usart_Write(data[1]); //
Usart_Write(data[2]); //check all data
Usart_Write(data[3]); //
Usart_Write(data[4]); //
}
}
}
but I always got wrong data when i execute it. Example when I send 123 from usart terminal in Mikro C, I will get 1111123333. The when I send 12345, also I will get 1111123333. could someone tell how to store data that I received via usart to array
Thanks Before.