One of the restrictions of
the 555 is that the triggering
pulse must be shorter than the
output pulse. Otherwise, the
output pulse will be as wide as
the trigger. This is why many
555 circuits use a capacitor to
couple the trigger signal to the
Another is that it only
triggers on the falling edge.
One-shot mode (mode 0)
of the PIC 555 replacement is
most easily selected by
grounding the mode pin
(Schematic 2). In all four one-shot modes, the selected
transition at pin 4 will trigger the output pulse.
There is a definition in the program that allows the
choice of triggering edge. The pulse width is calculated as
where VR2 is the voltage at the center tap of R2 and the
Resolution is determined by the voltage at pin 7 of the PIC
as described in Part 1 in the December 2016 issue. The
output pulse width is independent of the triggering pulse
width or VDD.
I have written three sample programs demonstrating
one-shot operation for the PIC12F1572 processor. The
reason for choosing this particular processor is simply that
it is the one I have used most recently for one of my
projects. Schematic 3 is the test setup I used for the three
programs. Note that it uses the
I/O pins a little differently than
the PIC 555 replacement in
order to allow the
programming/debug header to
The programs (available at
the article link) were written
mainly as programming
exercises and will benefit
those who have not done
much assembly language
work. I believe they are well
documented and should be
easy to follow.
I have used some
techniques that I believe are
good programming practice
such as giving symbolic names
to constant values and a
regular naming convention for
those names, as well as
Some of the conventions/
rules I use in my assembly
language programs are:
May use underscores
May not use periods
• Subroutine names
Significant words capitalized
May use periods
May not use underscores
• The name assigned to intermediate locations within a
subroutine use the full subroutine name followed by a
period and one or more digits.
• Almost every line in an assembly language program has
a meaningful comment.
• Sections of code that perform a specific task or subset
of a task have a leading comment describing that task.
• Subroutine comments before any code
Describe the function of the subroutine.
What is necessary to enter the routine: registers, R/W
What memory and/or registers are modified.
Where is the end result of the subroutine stored.
Program 1: MSMV-1 (MSMV = Mono Stable
MultiVibrator) demonstrates the simplest and fastest one-shot possible with a PIC. All it does is wait for the selected
input to transition, and then generate a pulse using two
assembly language instructions to turn an output bit on
then off. An outline of the program (other than
initialization) might be:
1. Wait for the trigger.
2. Turn on the pulse.
3. Turn off the pulse.
4. Go back to (1).
All three programs make
use of one of the hardware
features of this PIC in order to
select the triggering edge:
Interrupt-On-Change. This is a
feature of the PIC which
generates an internal signal
whenever the selected input
signal transitions. Either or
both edges can be detected.
Programs MSMV-1 and
MSMV- 2 do not actually use
May 2017 49
SCHEMATIC 3. Test circuit for the three programs.
SCHEMATIC 2. PIC 555 replacement, Mode 0.
VR2 (1) PW = 1024 Resolution VDD