| View previous topic :: View next topic |
| Author |
Message |
nasbyc
Joined: 27 Apr 2009 Posts: 50
|
|
Posted: Fri Jun 12, 2009 11:07 am |
|
|
hmmm
I already tested my program. For the first read, I got FAH and the second one FCH then it suddenly stop executing my program. I also try without loop for example
| Code: | keyin=fgetc(COM_B);
fprintf(COM_A,"keyin = %LX\n",keyin); |
When I try execute it, it generates continuous data. The program executed nonstop. Should I use code like in software uart ? |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jun 12, 2009 11:14 am |
|
|
The software UART has to constantly check the Rx pin for a start bit,
to see the beginning of an new incoming character. If you have code
(such as a printf statement for COM_A) that does something else for
a time period, the software UART will miss the incoming start bit.
It will miss the incoming byte on the Rx pin.
This is a limitation of the CCS software UART code. |
|
 |
nasbyc
Joined: 27 Apr 2009 Posts: 50
|
|
Posted: Fri Jun 12, 2009 11:28 am |
|
|
| Do you mean I have to remove the printf and put delay on it? Or check acknowledgement signal has been received? |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jun 12, 2009 11:44 am |
|
|
Don't use printf or delays, in a loop that is getting characters
from a software UART. The complete processing time of the
PIC must be used for the software UART only. If you take
time away from the software UART, you will lose incoming characters. |
|
 |
nasbyc
Joined: 27 Apr 2009 Posts: 50
|
|
Posted: Mon Jun 15, 2009 4:42 pm |
|
|
I tried using for loop to get the 5 bytes
| Code: | for(i=1;i<6;i++)
{
keyin[i]=fgetc(COM_B);
}
x1 =keyin[1];
fprintf(COM_A,"x1 = %LX \n",x1);
delay_ms(1000);
x2 =keyin[2];
fprintf(COM_A,"x2= %LX \n",x2);
delay_ms(1000);
y1 =keyin[3];
fprintf(COM_A,"y1 = %LX \n"y1);
delay_ms(1000);
y2 =keyin[4];
fprintf(COM_A,"y2 = %LX \n",y2);
delay_ms(1000);
button =keyin[5];
fprintf(COM_A,"button = %LX \n",button);
delay_ms(1000); |
this is the result that I got
x1 = FA
x2= FA
y1 = 08
y2 = 00
button = 00
I don't think the data are correct. is it because error in data sampling and it is correct that every data send by mouse to the host will has acknowledgement |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jun 15, 2009 4:55 pm |
|
|
| Post the manufacturer, name, and model number of the mouse. |
|
 |
nasbyc
Joined: 27 Apr 2009 Posts: 50
|
|
Posted: Mon Jun 15, 2009 5:01 pm |
|
|
I used two mouse
1. genius model:GM-03020U/A
2.LOGITECH:VALUE OPTICAL MOUSE M/N:M-BT83 P/N:810-000361 |
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jun 16, 2009 1:44 pm |
|
|
Post a link to documents that show the serial output protocol
used by these mouse devices. |
|
 |
nasbyc
Joined: 27 Apr 2009 Posts: 50
|
|
 |
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Wed Jun 17, 2009 2:30 am |
|
|
| nasbyc wrote: | I tried using for loop to get the 5 bytes
| Code: | for(i=1;i<6;i++)
{
keyin[i]=fgetc(COM_B);
}
x1 =keyin[1];
fprintf(COM_A,"x1 = %LX \n",x1);
delay_ms(1000);
x2 =keyin[2];
fprintf(COM_A,"x2= %LX \n",x2);
delay_ms(1000);
y1 =keyin[3];
fprintf(COM_A,"y1 = %LX \n"y1);
delay_ms(1000);
y2 =keyin[4];
fprintf(COM_A,"y2 = %LX \n",y2);
delay_ms(1000);
button =keyin[5];
fprintf(COM_A,"button = %LX \n",button);
delay_ms(1000); |
this is the result that I got
x1 = FA
x2= FA
y1 = 08
y2 = 00
button = 00
I don't think the data are correct. is it because error in data sampling and it is correct that every data send by mouse to the host will has acknowledgement |
Where is your definition of keyin ?
looking at this I bet it is defined as
int keyin[5];
Arrays in C have a 0 based index as default so you either need to define it as
int keyin[6]; // for indexes [0] to [5]
or change your loop and references
for (i=0; i<5; i++)
...
x1 = keyin[0];
What data are you expecting ? |
|
 |
nasbyc
Joined: 27 Apr 2009 Posts: 50
|
|
Posted: Sun Jun 28, 2009 3:47 pm |
|
|
hi there
I already managed to get the correct data. However this is only data from one mouse. What should I do if want to read the data from several mouse simultaneously? I already tried several attempts to read a mouse and display its values before collecting data from another mouse, but this will cause lost of data and reduce the performance of the system. |
|
 |
|