27220 Parallax Inc, 27220 Datasheet - Page 41

BOOK STAMPWORKS

27220

Manufacturer Part Number
27220
Description
BOOK STAMPWORKS
Manufacturer
Parallax Inc
Datasheet

Specifications of 27220

Accessory Type
Booklet
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
StampWorks
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Not applicable / Not applicable
humans) in terms of program functionality, and any design change would have been
more difficult to deal with.
The main program loop is handled with the DO-LOOP construct, and separate on-
and off-times are provided for flashing the LED. As with the pin configuration, we
can easily change the flash behavior by making a simple edit in the declarations
section. Since the LED has two states, having independent timing values for each
state gives us the greatest flexibility.
Taking it Further
Another advantage to direct use of output bits is that we can create code segments
like this:
Can you tell what’s happening here? Since Strobe is actually a bit variable (OUT0 in
this program), we can write any bit value to it – even a bit that’s part of another
variable. In the example above, BIT0 (the LSB) of cntr will be written to the LED
control pin through each iteration of the program loop.
configuration, this will cause the LED to light when the value of cntr is odd because
BIT0, which has a value of one, will be on when cntr is odd.
Q: Without changing the PAUSE 500 line, how could we make the LED flash at half
the current rate?
A: Write the value of cntr.BIT1 to the LED. Do you understand why this is?
DO
LOOP
When does one make the choice between DO-LOOP and GOTO Label? While both styles
are functionally equivalent, DO-LOOP provides the convenience of not having to define a
program label for the GOTO. The downside of DO-LOOP is that it can be difficult to follow
when very long sections of code are embedded within it – especially when indentation
guidelines are ignored.
While there is no hard and fast rule, a reasonable guideline is that about ten lines of code
or fewer are fine for DO-LOOP; longer sections are best used with GOTO Label.
Strobe = cntr.BIT0
PAUSE 500
cntr = cntr + 1
Using our active-high

Related parts for 27220