Forums

Keypad interface?

Started by arhodes19044 December 6, 2005
--- In basicx@basi..., "ybernikov" <ybernikov@y...> wrote:
>
> I did not try the I2C capabilities of ZBasic, but it must be much
> faster.
>
> -Yuri
>

I did. It is actually just about the actual speed which you have set
as the clock frequency. So at a clock setting of 400KHz, you do
approach that speed.

This is just the RAW speed of the data array that you are sending.
Filling the array and figuring out what to fill it with does take
longer, but the actual speed of the I2C driver is very fast.

Too bad that the ZX hardware SPI is not all that fast. I had to drop
down to the bit-banged SPI functions because the SD/MMC card does not
like sharing its bus (All transactions must be atomic). SPI FRAM,
OTOH, AFAIK, does not mind sharing, and transactions need not be
atomic. When the chip select is released, Ramtron FRAM pauses its
transaction, and it can be resumed. Not so for SD/MMC.


--- In basicx@basi..., "ybernikov" <ybernikov@y...> wrote:
> 83000 / 20 = 4150 bytes/sec


I think I remember measuring the BX bit-banged I2C clock at somewhere
around 3000 Hz.

-Tony



--- In basicx@basi..., "arhodes19044" <spamiam@c...> wrote:
> Too bad that the ZX hardware SPI is not all that fast. ...

SPI on both the BX-24 and the ZX-24 can be very fast; the top speed is
1.84MHz on the BX and 7.37MHz on the ZX. The issue to keep in mind is
that your SPI device will have its chip select asserted only during
the execution of each SPICmd(). Chip select has to be de-asserted
when SPICmd() is done because the CPU needs to use the SPI channel to
fetch instructions. The other limitation that might come into play is
the 255 byte data length limit for SPICmd().

It is possible to implement a bit-bang SPI interface in the ZX
firmware. I suspect that the top speed would be in the range of
500KHz to 1MHz.

Don


>
> I think I remember measuring the BX bit-banged I2C clock at somewhere
> around 3000 Hz.
>
> -Tony
>

This means that the "real life" speed of BX-24 is more than 10 times
slower than the "best case" speed for the specific instructions like b
= b + 1. I understand, that this is not Netmedia's guilt - all
manufacturers do the same trick for the marketing purposes.


--- In basicx@basi..., "ybernikov" <ybernikov@y...> wrote:

> This means that the "real life" speed of BX-24 is more than 10 times
> slower than the "best case" speed

Well, I did not calculate the number of instructions involved in each
cycle of the I2C clock, but there are quite a few. I am not surprised
that the clock rate is going to be WELL below the rated speed of a
single instruction.

It would be interesting to see what the average instruction duration
is for this sort of operation. One would have to look hard at the
code and figure out the number of instructions, on average, per clock
cycle, then get a good measurement of the I2C clock rate. Not a hard
task, just a little tedious. Possibly informative regarding
bottlenecks and optimizing techniques.

-Tony


--- In basicx@basi..., "ybernikov" <ybernikov@y...> wrote:
> This means that the "real life" speed of BX-24 is more than 10 times
> slower than the "best case" speed for the specific instructions like
> b = b + 1. I understand, that this is not Netmedia's guilt - all
> manufacturers do the same trick for the marketing purposes.

Part of the problem is that attempting to convey an accurate and
complete idea of processor speed is a difficult proposition. In
particular, what consititutes an instruction? Given that the mapping
from a line of source code (one perception of an instruction) to pcode
instructions (another perception of an instruction) varies widely, no
one metric is going to adequately describe the processor speed.

This problem is not unique to the BX-24, Basic Stamp or ZX-24, of
course. With the AVR chips themselves, Atmel describes them as
executing as fast as 1 MIP per megahertz of clock speed. Of course,
that only applies to instructions that execute in 1 clock cycle.
Although a fair number of the instructions do, many don't.

In my opinion, the NetMedia claim of a best case speed of 83,000 is
accurate but incomplete. That is why I describe the ZX-24 speed
as "up to 172,000 instructions per second".

Don
http://www.zbasic.net


[]

Thank you for the detailed explanation. I agree that the problem of
speed is rather complicated - quite often it resembles comparing
apples to oranges. May be I used too strong language when I talked
about "marketing tricks" :)

-Yuri