the first key press during each blink
will actually make it to the Terminal
Window; the others will be lost. In
the next installment of the Primer,
we’ll make the necessary modifications to capture all the data that is
sent, but for now we’ll focus on our
If you read through your printout
for the “Hserin Test” program, you
can see that it’s fairly thoroughly
commented. However, there is one
important aspect of the program that
I didn’t have space to explain in the
comments, so let’s discuss that now.
The PICAXE system has three built-in
variables for use with background
• Hserinflag is a flag that indicates
that new data has arrived in the
background. It is initially reset to 0
and as soon as a background serial
receive has occurred, the system
NEW! HIDmaker FS for Full Speed FLASH PIC18F4550
Creates complete PC and Peripheral
programs that talk to each other over
USB. Ready to compile and run!
• Large data Reports
• 64,000 bytes/sec per Interface
• Easily creates devices with multiple
Interfaces, even multiple Identities!
• Automatically does MULTITASKING
• Makes standard or special USB HID
NEW! “Developers Guide for USB HID
Peripherals” shows you how to make
devices for special requirements.
Both PC and Peripheral programs
understand your data items (even odd
sized ones), and give you convenient
variables to handle them.
PIC18F Compilers: PICBASIC Pro,
MPASM, C18, Hi-Tech C.
PIC16C Compilers: PICBASIC Pro,
MPASM, Hi-Tech C, CCS C.
PC Compilers: Delphi, C++ Builder,
Visual Basic 6.
HIDmaker FS Combo: Only $599.95
automatically sets it to 1. Your
program can then test hserinflag
to check whether there is data
available in the scratchpad — that’s
the function of the “if” statement
block in the program.
• Hserptr points to the location in
the scratchpad in which the next
received data byte will be written.
Pointers are a powerful way of
accessing and manipulating
data, but the details can get
• Ptr points to a location in the
scratchpad from which we can
access (read) a received data byte.
(We’ll discuss the use of pointers in
the next installment of the Primer.)
To keep things simple, we’ll avoid
using the built-in pointers and
simply access the data in the
scratchpad location 0.
DOWNLOAD the HIDmaker FS Test Drive today!
Each time the data has been
accessed and sent to the Terminal
Window, the built-in variables must
be reset. We’ll get into the reasons
and details next time. For now, we’ll
just use the “ResetAll” subroutine for
that purpose. If you haven’t already
done so, use the Programming Editor
to download the modified
“IRMB_Remote” program (the one
you renamed and saved earlier) to
your IRMB circuit and download
“Hserin Test.bas” to your 28X1 circuit.
Be sure to leave your programming
adapter and cable connected
between the 28X1 and your PC so
you can view the received data in the
Terminal Window. Point your SIRC
TV remote at the IRMB and press a
key. You should see a data byte
appear in the Terminal Window.
Remember, there will most likely be a
delay of a second or more while the
28X1 is busy blinking its LED.
Experiment with pressing
multiple keys during a single blink.
You’ll see only the first key press will
show up. Next time, we’ll modify our
program so that it can capture and
display every key press we make. If
you like a challenge, study the relevant documentation in the PICAXE
manual and see if you can make the
necessary changes before we discuss
them here. See you then. NV