Thanks,
I have done further tests, and I am getting better performance than I
thought, but still not what I had hoped for. It takes average 700us to
send 82 bytes and 1700us to receive 102. The slower receive is no doubt
due to the hardware having to read 2 nybbles, I am having new hardware
done to make it a single read, and then I should get the same
performance from the write as read. Of course, the other end was taking
1000us to respond!
If this is the best performance I can expect, I guess I will have to try
something else!
BTW: -O2 did not seem to affect the speed at all. I am using qcc.
Simon
code follows:
////
SETTLE is NOT defined!
int ppi_write(int nbytes, char *buf)
{
register unsigned char *p = buf;
register int i;
unsigned char data, test;
unsigned long j = loclock(1) + rb_timeout;
float v = 3.4;
long rv;
i = nbytes;
while (i–)
{
#ifdef SETTLE
/* Check IACK is stable */
do
{
test = (in8(STATUS) & IACK);
if (loclock(0) >= j)
{
printf(“RB: Write timeout on testing IACK\n”);
goto timeout;
}
//printf(“Test is %2x %2x\n”, test, IACK & IACKTRUE);
} while (test == (IACK & IACKTRUE));
#endif
/* Present data on output latch */
out8(DATA, *p++);
/* Assert IVALID */
out8(CONTROL, SETIVAL);
/* Await IACK */
while ((in8(STATUS) & IACK) != (IACK & IACKTRUE))
{
// Timeout code here
if (loclock(0) >= j)
{
printf(“RB: Write timeout at %d bytes of %d\n”, nbytes -
i -1, nbytes);
goto timeout;
}
//printf(“Waiting IACK\n”);
}
/* De-assert IVALID */
out8(CONTROL, IDLE);
#ifdef SETTLE
do
{
data = (in8(CONTROL) & 0x1f);
if (loclock(0) >= j)
{
printf(“RB: Write timeout on de-asserting IVALID\n”);
goto timeout;
}
} while (data != IDLE);
#endif
}
return nbytes;
timeout:
return RB_TIMEOUT;
}
///
In article <D4907B331846D31198090050046F80C905C8BE@exchangecal.hq.csical
…com>, Rennie Allen <RAllen@csical.com> writes
40 bytes every 4ms only works out to be 10KB/sec. With a driver (i.e.
without building the driver into your apps function), you should easily
be able to obtain a rate of less than 400us for every 40 bytes (i.e.
10us/byte which is at least 10x faster than what you are seeing) on the
hardware you have.
Clearly there is something very wrong here regardless of any efficiency
differences with assembler vs C. Are you using the parallel port
interrupt ? Could you post your code ?
-----Original Message-----
From: Simon Wakley [mailto:> Simonospam@cameracontrol.com> ]
Posted At: Tuesday, July 10, 2001 11:04 AM
Posted To: os
Conversation: Assembly code speed compared to C
Subject: Assembly code speed compared to C
I talk to some hardware via the parallel port. I write 1 byte out and
read back 2 sets of 4 bits to get a byte back. This is to some custom
outdated hardware. I wrote a device driver to do this, and it was
horribly slow. I then wrote the code into my function (root enabled
etc) and now it is almost tolerably fast, but it is slower than I need.
It takes 2-4ms to write and read about 40 bytes.
If I wrote it in assembler would it be a lot faster?? If so, is there
anywhere I can read up on doing so with QNX RTP on Intel 350Mhz Pentium.
Thanks
–
Simon Wakley
Visit our web site at <<www.cameracontrol.com>>