The Basic Stamp - PowerPoint PPT Presentation

About This Presentation
Title:

The Basic Stamp

Description:

The Basic Stamp Instruction Set Architecture The Microprocessor A microprocessor is a computer that typically has an architecture that is well suited to embedded ... – PowerPoint PPT presentation

Number of Views:136
Avg rating:3.0/5.0
Slides: 20
Provided by: rein213
Category:

less

Transcript and Presenter's Notes

Title: The Basic Stamp


1
The Basic Stamp
  • Instruction Set Architecture

2
The Microprocessor
  • A microprocessor is a computer that typically has
    an architecture that is well suited to embedded
    systems applications
  • Built in memory
  • Built in I/O pins and registers
  • Hardware interface support
  • The instruction set is typically of the Reduced
    Instruction Set Computer (RISC) type
  • A minimalist list of instructions required to
    manipulate hardware devices
  • Nothing fancy
  • They are usually rolled out as a family of
    devices
  • Various capabilities to suite a multitude of
    embedded applications
  • Were using the BASIC Stamp BS2
  • The microprocessor is a PIC16C57
  • There are a family of BASIC Stamp processors
    including BS1, BS2, BS2E, BS2SX, BS2P, BS2PE,
    BS2PX

3
The BS2 Instruction Set
  • While most microprocessor instruction sets are
    specified in Register Transfer Language (RTL) and
    assembly language, the BS2 is specified in PBASIC
  • The architecture is specifically designed to
    execute PBASIC instructions

4
Preliminaries
  • The BASIC Stamp IDE is designed to work with the
    entire family of BASIC Stamp devices
  • Thus, it is important that you provide the
    correct compiler directives in your code
  • 'STAMP BS2 'STAMP directive (specifies a BS2)
  • 'PBASIC 2.5 ' PBASIC Version directive
  • The IDE has buttons to insert these into your
    code (you dont have to memorize them)

5
The Instructions
6
Branching
  • GOSUB address
  • Jump to subroutine, address (label)
  • ON offset GOSUB address1, address2, address3,
  • Call the subroutine at the 0-based offset in the
    address label list
  • RETURN
  • Return from a GOSUB or ON GOSUB command
  • GOTO address
  • Jump to a specific address (label)
  • ON offset GOTO address1, address2, address3,
  • Jump to the 0-based offset in the address label
    list

7
Looping
  • DO
  • statements
  • LOOP
  • DO WHILE (condition)
  • statements
  • LOOP
  • DO UNTIL (condition)
  • statements
  • LOOP
  • DO
  • statements
  • LOOP WHILE (condition)
  • DO
  • statements
  • LOOP UNTIL (condition)
  • FOR counter start TO end STEP value
  • statements
  • NEXT
  • Beware of counting down, strange things may
    happen due to 2s complement notation
  • EXIT
  • Bail out of a loop early (like break in Java)

8
Conditional Branching
  • IF condition THEN address
  • Goto address label if condition is true
  • IF condition THEN
  • statements
  • ELSEIF condition THEN
  • statements
  • ELSE
  • statements
  • ENDIF
  • Conditional statement, ELSEIF is optional
  • BRANCH value, case0, case1, case2
  • Equivalent to
  • IF value 0 THEN case0
  • IF value 1 THEN case1
  • IF value 2 THEN case2
  • SELECTCASE

9
Data Declarations RAM
  • symbol VAR type
  • Type can be
  • Bit 1 bit
  • Nib 4 bits
  • Byte 8 bits
  • Word 16 bits
  • Arrays
  • symbol VAR type(entries)
  • Alias
  • symbol VAR symbol
  • Partial access though suffixes
  • .BITn
  • .NIBn
  • .BYTEn
  • .LOWBYTE
  • .HIGHBYTE

10
Data Declarations EEPROM
  • DATA value1, value2, value3,
  • Write data values to EEPROM to be read later with
    READ
  • Differs from VAR in that DATA uses EEPROM and VAR
    uses RAM
  • READ location, variable
  • read a value from the EEPROM that was previously
    loaded with a DATA command
  • WRITE location, data
  • write data to address location in the EEPROM

11
Data access
  • LOOKDOWN value, item0, item1, item2, result
  • Assign the 0-based index of value in the item
    list into result
  • No assignment if value is not in the item list
  • LOOKUP index, value0, value1, value2, result
  • Assign the value from item list at 0-based index
    into result
  • No assignment if index is too big

12
Termination
  • END
  • End the program, go to low power mode
  • STOP
  • Stop program execution without going into low
    power mode

13
Power Management
  • NAP period
  • go to reduced power mode for 2period 18 mSecs
  • SLEEP duration
  • put the BASIC stamp into low power mode for
    duration Seconds rounded up to units of 2.3
    seconds
  • PAUSE duration
  • Sleep for duration mSecs (stay in normal power)

14
Input/Output
  • BUTTON pin, downstate, delay, rate, workspace,
    targetstate, address
  • Read button state with debounce options
  • COUNT pin, duration, variable
  • Count the number of 0-1-0 or 1-0-1 transition for
    duration time in mSec
  • HIGH pin
  • Set a high signal on pin
  • LOW pin
  • Set a high signal on pin

15
Input/Output
  • INn
  • Read from pin n
  • OUTn
  • Write to pin n
  • TOGGLE pin
  • Invert the state of the pin

16
Input/Output
  • FREQOUT pin, duration, frequency
  • Output a sine wave on a pin
  • PWM pin, duty, duration
  • Use pulse-width modulation to convert a digital
    value to analog
  • PULSIN pin, state, variable
  • Measure the width of an incoming pulse on the
    specified pin
  • PULSOUT pin, duration
  • Send a pulse to pin of width duration in units of
    2 uSecs

17
Input/Output
  • SERIN
  • Read RS232 formatted data on an I/O pin
  • SEROUT
  • Write RS232 formatted data on an I/O pin

18
Miscellaneous
  • Math
  • SIN, COS, ABS, SQR, RANDOM
  • Note that these do not return floating point
    numbers
  • The return integers within some defined range
  • DEBUG output, output,
  • Write data to the debug monitor window

19
And Then Some
  • There are many more commands
  • Ive just touched on the most useful ones for
    what we do
  • Online help installed with the IDE shows all
  • Look for those labeled BS2
  • Full manual can be gotten here
  • http//www.parallax.com/dl/docs/prod/stamps/web-BS
    M-v2.2.pdf
Write a Comment
User Comments (0)
About PowerShow.com