variable. In the first syntax variation above, the mask
parameter of the setintflags command can be used to
specify which flag bit(s) we want to trigger the interrupt;
any flag bit masked by a “0” will be ignored. The setintflags
command allows for various combinations, but we’re only
interested in the hserinflag (bit 5 of flags), so we’ll specify
mask as %00100000, and ignore all the other flags.
The flags parameter can be used to specify which
condition (high or low) of the flag(s) we want to trigger an
interrupt. Again, we’re only interested in the hserinflag
which is automatically set to “1” (high) when background
serial data is received. So, we will also specify flags as
%00100000. Actually, because we’re ignoring all the other
flags, it doesn’t matter what value (0 or 1) we place in any
of the other bit positions, but it could be confusing to
change any of the other zeros to ones.
By now, I’m sure you’re glad to hear that we’ve finally
covered all the theoretical details that we need for our first
experiment! This would be a good time to take a break
and maybe stretch a little. When you’re
ready, we’ll move on to our first
experiment.
Experiment 1: Hserin with
an Interrupt and Direct
Addressing
This experiment is very similar to our
two 20X2 experiments from last time.
The main difference is that we will be
using the hserinflag interrupt this time.
Figure 1 presents the schematic for both
experiments this month, and Figure 2 is a
photo of my breadboard setup. As we did previously, we’ll
again be using the Cool Term program (or whichever
terminal program you prefer) in line mode, so that we can
type a complete line of text and then press the enter (or
return) key on the Mac or PC to transmit the entire line of
serial data to the 20X2.
I also again used 115,200 for the baud rate, but if you
had any problems with that previously you may want to
drop back to 57,600 baud. (We’ll discuss baud rate
changes shortly.) When you’re ready to configure your
terminal program for the experiment, be sure to specify
the following settings:
• In the “Serial Port Options,” select 115,200 baud
and whichever serial port your PL2303HX cable is
connected to. (Mine always shows up as “usbserial;” the
same may be true for your cable.)
• In the “Terminal Options,” select “Line Mode” and
enable the “CR+LF” option for the “Enter Key Emulation.”
The software for Experiment 1
( Hser20X2IntDirect.bas) is available at
the article link. Now would be a good
time to get it, along with the other
program we’ll be using this month.
Before you run the program on your
20X2 breadboard setup, let’s take a look
at the details of the interrupt subroutine.
(You may want to print a hard copy of
the program as a reference for our
discussion.)
As usual, the following numbered
12 September 2015
Post comments on this article and find any associated files and/or downloads at
www.nutsvolts.com/index.php?/magazine/article/september2015_PICAXEPrimer.
■ FIGURE 1. Schematic for Experiments 1 and 2.
■ FIGURE 2. Breadboard setup for Experiments 1 and 2.