the basic stamp n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
The Basic Stamp PowerPoint Presentation
Download Presentation
The Basic Stamp

Loading in 2 Seconds...

play fullscreen
1 / 19

The Basic Stamp - PowerPoint PPT Presentation


  • 117 Views
  • Uploaded on

The Basic Stamp. Instruction Set Architecture. 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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'The Basic Stamp' - geoff


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
the basic stamp

The Basic Stamp

Instruction Set Architecture

the microprocessor
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
  • We’re 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
the bs2 instruction set
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
preliminaries
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 don’t have to memorize them)
branching
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
looping
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 2’s complement notation
  • EXIT
    • Bail out of a loop early (like break in Java)
conditional branching
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

SELECT…CASE

  • compact form of an IF THEN ELSEIF command
data declarations ram
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

.LOWNIB

.HIGHNIB

data declarations eeprom
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
data access
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
termination
Termination

END

  • End the program, go to low power mode

STOP

  • Stop program execution without going into low power mode
power management
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)
input output
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
input output1
Input/Output

INn

  • Read from pin n

OUTn

  • Write to pin n

TOGGLE pin

  • Invert the state of the pin
input output2
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
input output3
Input/Output

SERIN

  • Read RS232 formatted data on an I/O pin

SEROUT

  • Write RS232 formatted data on an I/O pin
miscellaneous
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
and then some
And Then Some…
  • There are many more commands
  • I’ve 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-BSM-v2.2.pdf