Shop OBEX P1 Docs P2 Docs Learn Events
Question? — Parallax Forums

Question?

wafa86wafa86 Posts: 44
edited 2010-11-22 20:22 in BASIC Stamp
hi

In BASIC Stamp® 2px Microcontroller (BS2PX-IC) manual was written that the Processor Speed is 32 MHz Turbo and the Program Execution Speed is ~19,000 instructions/sec. In the SX48BD (the Microcontroller of BS2PX module) datasheet was written:"Throughput is enhanced by operating
the device at frequencies up to 75 MHz" and "13.3 ns instruction cycle, 39.9 ns internal interrupt response at 75 MHz", now I am confused!!; at what speed the BS2PX module is operate on 75MHz or 32MHz, and how many insttructions per second theMicrocontroller can execute?!!!:confused:

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-11-13 07:39
    Remember that what is running on the SX48 is an interpreter program for PBasic. Also remember that power consumption (and heat dissipation) depends on processor speed. Even though the SX48 can run with a system clock up to 75MHz, that doesn't mean that it should for every application. 32MHz was probably chosen as a compromise between speed and power consumption.

    The PBasic program is not stored within the SX. It's stored in an external I2C serial EEPROM which operates at a clock up to about 400KHz. There's an overhead of 1 byte for each sequential read operation and each byte takes 9 clocks. A 2 byte long instruction could be read at about 14000 per second. Some instructions are only 1 byte long and a mix of 1 and 2 byte instructions could give an average speed of 19000 per second.
  • wafa86wafa86 Posts: 44
    edited 2010-11-22 14:07
    how can I use if statement to compare between ranges that is below 0 which are negative numbers, such is

    Countdis VAR Word

    DO

    IF (Countdis < 0) THEN

    DEBUG "YES",CR

    ELSE

    DEBUG "NO",CR

    PAUSE 1000

    ENDIF

    LOOP

    I tried this code but I notice that the if statement only used when campare between unsigned numbers. Is there any techniqe I can use to do the previous code???!!!
  • Mike GreenMike Green Posts: 23,101
    edited 2010-11-22 20:22
    You have to keep in mind the relationship between unsigned and signed numbers. In particular, you have the following unsigned 16-bit ranges:

    $FFFF = -1
    --to--
    $8000 = -32768
    -and-
    $7FFF = +32767
    --to--
    $0000 = 0

    Note that you can compare negative values using unsigned arithmetic and you can compare positive values using unsigned arithmetic, but it's in comparing positive to negative values that gets you into trouble.

    If you really want to do signed comparisons, you have to first separate the quadrants (+/+ and -/- from +/- and -/+). The easiest way is by comparing the signs of the numbers like:

    IF (a & $8000) = (b & $8000) THEN GOTO sameSign ' < and > will be valid
    IF (a + $8000) < (b + $8000) THEN GOTO trueLess ' If opposite signs

    Try these out on paper with sample values.
Sign In or Register to comment.