Library of Routines
for PIC12F629
A-E
E-P P-Z
Pause
To create a "pause" instruction:
Loop
goto $
This will cause the microcontroller to keep looping the same instruction.
Poll
See
also Switch
The action of POLLING means to "look
at - on a regular basis." It generally refers to an
input device such as switch or push button. A push button can be pressed
and released in less than 10th second and this means it must be scanned
or polled 10 times a second (100mS).
This means you have 100,000 machine cycles available between "looks."
Most programs consist of a Main routine and this is looped
on a regular basis. As a program gets larger and larger, the Main
routine may loop at a slower rate (mainly due to delay sub-routines
needed for some of the operations) and you may exceed the 100,000
limit.
The answer is to place the "look" feature inside the delay
sub-routine. The following sub-routine has a "Look"
feature inside a Delay:
Delay
Delay1
Not
Delay2
Main
|
MOVLW 01h
MOVWF 2C
NOP
DECFSZ 2A,1
GOTO Delay1
BTFSS 05,0
GOTO Not
BSF 2F,0
RETLW 00
BCF 2F,0
BCF 2F,1
DECFSZ 2B,1
GOTO Delay1
DECFSZ 2C,1
GOTO Delay1
RETLW 00
CALL Delay
other instructions
BTFSS 2F,0
GOTO Main
BTFSC 2F,1
GOTO Main
BSF 2F,1
CALL Action
GOTO Main |
;Approx
300mS per "unit"
;Look at push-button line on port A
;Button not pressed
;Set button-press flag
;Clear button-press flag
;Clear "action"
flag
;Has button been pushed?
;No.
;Yes. Has "action" already been performed?
;Yes.
;No.
|
|
The Delay sub-routine includes instructions
to look at a button and set a flag (BSF
2F,0) when it is pressed.
The micro comes out of the Delay routine with the flag SET. The
flag is then looked at in Main and the appropriate sub-routine is
executed.
This sequence may be executed very quickly and the micro may return
to Delay before the button is released. The "action" flag
(BTFSC 2F,1) prevents the action being
carried out more than once for a single button-press.
When the button is released, both flags are cleared.
Pseudo Instructions
- these are additional
Instructions understood by MPASM:
|
Mnemonic
|
Description
|
Equivalent
Operation(s)
|
Status
|
|
ADDCF
|
f,d
|
Add Carry to File
|
BTFSC
INCF
|
3,0
f,d
|
Z
|
|
ADDDCF
|
f,d
|
Add Digit Carry to File
|
BTFSC
INCF
|
3,1
f,d
|
Z
|
|
B
|
k
|
Branch
|
GOTO
|
k
|
-
|
|
BC
|
k
|
Branch on Carry
|
BTFSC
GOTO
|
3,0
k
|
-
|
|
BDC
|
k
|
Branch on Digit Carry
|
BTFSC
GOTO
|
3,1
k
|
-
|
|
BNC
|
k
|
Branch on No Carry
|
BTFSS
GOTO
|
3,0
k
|
-
|
|
BNDC
|
k
|
Branch on No Digit Carry
|
BTFSS
GOTO
|
3,1
k
|
-
|
|
BNZ
|
k
|
Branch on No Zero
|
BTFSS
GOTO
|
3,2
k
|
-
|
|
BZ
|
k
|
Branch on Zero
|
BTFSC
GOTO
|
3,2
k
|
-
|
|
CLRC
|
|
Clear Carry
|
BCF
|
3,0
|
-
|
|
CLRDC
|
|
Clear Digit Carry
|
BCF
|
3,1
|
-
|
|
CLRZ
|
|
Clear Zero
|
BCF
|
3,2
|
-
|
|
LCALL
|
k
|
Long Call
|
BCF/BSF
BCF/BSF
CALL
|
0x0A,3
0x0A,4
k
|
|
|
LGOTO
|
k
|
Long GOTO
|
BCF/BSF
BCF/BSF
GOTO
|
0x0A,3
0x0A,4
k
|
|
|
MOVFW
|
f
|
Move File to W
|
MOVF
|
f,0
|
Z
|
|
NEGF
|
f,d
|
Negate File
|
COMF
INCF
|
f,1
f,d
|
Z
|
|
SETC
|
|
Set Carry
|
BSF
|
3,0
|
-
|
|
SETDC
|
|
Set Digit Carry
|
BSF
|
3,1
|
-
|
|
SETZ
|
|
Set Zero
|
BSF
|
3,2
|
-
|
|
SKPC
|
|
Skip on Carry
|
BTFSS
|
3,0
|
-
|
|
SKPDC
|
|
Skip on Digit Carry
|
BTFSS
|
3,1
|
-
|
|
SKPNC
|
|
Skip on No Carry
|
BTFSC
|
3,0
|
-
|
|
SKPNDC
|
|
Skip on No Digit Carry
|
BTFSC
|
3,1
|
-
|
|
SKPNZ
|
|
Skip on Non Zero
|
BTFSC
|
3,2
|
-
|
|
SKPZ
|
|
Skip on Zero
|
BTFSS
|
3,2
|
-
|
|
SUBCF
|
f,d
|
Subtract Carry from File
|
BTFSC
DECF
|
3,0
f,d
|
Z
|
|
SUBDCF
|
f,d
|
Subtract Digit Carry from File
|
BTFSC
DECF
|
3,1
f,d
|
Z
|
|
TSTF
|
f
|
Test File
|
MOVF
|
f,1
|
Z
|
Pull-ups
The PIC12F629 has individual pull-ups of about 47k on each line,
that can be activated via the following code. When a line is made
into a input, the pull-up is not active, but is re-activated when
the line is changed to output.
Pin 4, GPIO,3 (GP3) is an INPUT-ONLY pin and does not
have a pull-up.
In the following instructions, GPIO,5 will have a weak pull-up. A
push-switch is connected between GPIO,5 and ground. When the switch
is pressed, the input will go LOW. This is called an active
LOW input. GPPU is an active LOW enable bit. It is written:
GPPU. In the program
it is identified as NOT_GPPU as the "Word" document does not overlines.
When this bit is cleared (bcf), pull-ups are enabled by individual
pot latch values. movlw b'11101000' ;Specify GPIO port direction
movwf TRISIO ;Set GPIO ports as xxIOIOOO
bcf OPTION_REG
bcf NOT_GPPU ;enable weak pull-up
bsf WPU, 5 ;enable wpu on GPIO 5 only
Random
number see also
Mask
A random number can be created by
monitoring the TIMER file and looking at this file when a player has
pushed a button.
|
Get_Random |
movf tmr0,0
andlw 0x03
movwf 27h
retlw 00 |
;Read the PIC's timer register and put it in W
;mask all but bit0 and bit1 to get values 0,1,2,3.
;move random number to file 27h (the RANDOM
; number
file). |
|
To get a random number: 0-7, mask all
but bits 0,1,2: andlw 0x07
The random number file can be incremented if zero is not
needed (this will be the second instruction in the sub-routine
above) and then "andlw" is carried out.
Here is another Random Number Generator form
Andrew Warren [fastfwd
at ix.netcom.com] of Fast Forward Engineering - San Diego, California.
Load a register called "RANDOM" with any non-zero value, then call this
routine each time you'd like a new pseudo-random value: LFSR =
Linear Feedback Shift Register. LFSR: RLF RANDOM,W
RLF RANDOM,W
BTFSC RANDOM,4
XORLW 1
BTFSC RANDOM,5
XORLW 1
BTFSC RANDOM,3
XORLW 1
MOVWF RANDOM
RETLW 0
Scott Dattalo says:
[with the double RLF at the start of this routine,] Andy is implementing
'roll left' where the most significant bit of RANDOM will get copied to
least significant position. This is how it works. The first RLF will
copy the most significant bit of RANDOM into the carry. What ever was in
the carry prior to the first RLF will get copied into the least
significant bit position - but we don't care. Also, since the
destination is the W register, the variable RANDOM is unaffected. The
second RLF repeats the same rotate operation, but this time the carry
has been initialized to the MS bit of random. So this second rotate will
copy the MS bit into the least significant bit. All of the other bits
are of course shifted left one bit position.
Read
a File
Files can be used to store temporary data.
A file can be read by moving (it actually gets copied and the
original is not altered) it into the W register via an
instruction such as: movf 3Ch,0
A file can be "read" and an action performed if it is zero. Use
instructions such as:
decfsz 3Ch,0
goto button-1
;the file is not zero
goto button-2
;the file is zero
Any bit in a file can be read and an action carried out. In this
case bit 3 is tested:
btfss 3Ch,3
goto button-1 ;bit 3 is
"0"
goto button-2
;bit 3 is "1"
Read
Data
The PIC12F629 does not have a feature such as "Read Data"
or "Read an Instruction." Data can be added to a program
(when writing the program) in the form of a table (see Table) and this data cannot be altered. Each
item in the table can be read by writing an instruction such as:
retlw 4Fh
retlw 22h
retlw 0CCh
Temporary data can be stored in a file or set of files. There are
68 files (from 20h to 5F).
Data can also be added to the EEPROM section. This is 128 bytes of
data and can be changed up to 1 million times. The data will be kept
when the power is removed.
Remove
bits see AND
and Mask
Return
- not used for PIC12F629, use:
Ret lw
00
This instruction must be somewhere in each sub-routine if the
sub-routine has been CALLED. It is generally
at the end, but quite often programming will create a Return
part-way through a routine. The instruction to use for a
PIC12F629 is: retlw 00 to
retlw 0FFh
See CALL and GOTO for more details.
RETLW 00 to FF - Return
with Literal in W
A sub-routine
can carry out an operation and set a flag. Alternatively it can
return with a value in W.
If a sub-routine generates two or three different results, the RETLW
00 to FF instruction can Return with the appropriate value in W.
RETLW 00 to FF is used for each value of data in a Table.
(see Table)
Rotate
This is the same as SHIFT. All the
bits in a file are moved to the left or right through the CARRY.
Carry is located in the STATUS file (03,0).
It requires 9 shifts (rotates) to get the bits back to the original
position.
The CARRY must be cleared (BCF 03,0) if you don't want it to appear
in the file.
RLF (Rotate Left File)
increases the value of the contents (doubles the value).
RRF (Rotate Right File) decreases the value
of the contents (halves the value).
The following two instructions will
rotate the contents of a file register without loosing data in the "Carry
Flag".
Rotate right or left can be implemented. Note
that the carry flag is changed.
Enter with "abcdefgh" and leave with
"bcdefgha"
rlf Register, w ;Load Carry with the highest bit
rlf Register, f ;Shift left
or
Enter with "abcdefgh" and leave with
"habcdefg"
rrf Register, w ;Load Carry with the lowest bit
rrf Register, f ;Shift right
Same
To find out if two numbers are the same,
they are XORed together. See XOR and Comparison
SetUp
The first sub-routine in a program is SetUp. It sets the direction
for each Input/Output line and clears any other files to get them
ready for incrementing etc.
To make a line INPUT or OUTPUT, see INPUT, OUTPUT.
Instructions between
BSF 03,5 and BCF 03,5 are dealing with
files files in Bank 1. For instance, if files 05 is loaded with 02,
this is actually the TRISIO file. This file controls the direction of the Input/Output lines
of GPIO and when it contains 0's, all the lines are output. Note:
GP3 is input only
SetUp
|
ORG
0
BSF 03,5
MOVLW 02
MOVWF TRISIO
BCF 03,5
CLRF 2F
CLRF GPIO
GOTO Main |
;This
is the start of memory for the program.
;Go to Bank 1
;Load W with 0000 0010
;Make GP1 input
;Go to Bank 0 - the program memory area.
;Clear flag file
;Clear GPIO of junk
|
|
Shift
see Rotate
SLEEP
This instruction puts the micro to sleep. This is
also called "power-down mode."
The micro stops executing the program when it comes to this
instruction.
If the Watchdog Timer is enabled, it will be cleared but will keep
incrementing.
The In/Out lines maintain the status they had before SLEEP was
executed.
For the lowest consumption in SLEEP, all output lines must not drive
any circuitry before the SLEEP instruction.
On-chip pull-ups must also be turned off to reduce the current
consumption during SLEEP.
The micro will wake up from SLEEP via one of the following:
1. Taking MCLR
pin LOW
2. Watchdog Timer wake-up (if watchdog is enabled)
3. Interrupt from GP2/INT pin
4. GPIO change
5. Peripheral interrupt.
On wake-up from SLEEP, the WDT is cleared.
When the SLEEP instruction is being executed, the next instruction
(PC + 1) is pre-fetched. For the micro to wake up through an
interrupt event, the corresponding interrupt enable bit must be set
(enabled). Wake up is regardless of the state of the GIE bit. If the
GIE bit is clear (disabled) the micro continues execution at the
instruction after SLEEP. If the GIE bit is set (enabled) the micro
executes the instruction after SLEEP then branches to the interrupt
address (004h). In the case where the instruction following SLEEP is
not desirable, the user should have a NOP after the SLEEP
instruction.
The TO and
PD bits in the STATUS
register can be used to determine the cause of RESET. The
PD bit, which is set
on power-up, is cleared when SLEEP is invoked. The
TO bit is cleared if
WDT wake-up occurred.
The SLEEP instruction is:
sleep
To send the micro to the "sleep_micro" sub-routine, the following
instruction is needed:
goto sleep_micro
The simplest sub-routine for SLEEP is:
sleep_micro
sleep To set GPIO 3 for wake-up from sleep: This has
been tested in Greeting card "Decision Maker" bsf
status, rp0
;Bank 1
movf GPIO,0
movlw b'00001001'
;must clear the GPIF flag!!
movwf INTCON
bsf IOC,3
sleep
nop
bcf
status, rp0 ;bank 0
goto xxx If the Watchdog timer is enabled, the micro will come out of SLEEP
and goto main.
The watchdog will reset after
18,000uS (18m) and wake the micro.
If 18mS is too short, a prescaler can be added to increase the WDT
time by 2, 4, 8, 16, 32, 64 or 128. The maximum time is 18mS x 128
= 2.3sec
The micro contains an 8-bit prescaler register that can be assigned
to Timer0 or Watchdog. This prescaler register is not readable
or writable.
To set the prescaler to the WDT, bit 3 of the OPTION REGister must
be set. The instruction is:
bsf
STATUS, RP0 ;select bank 1
bsf OPTION_REG,3
or
movlw b'xxxx1xxx'
movwf OPTION_REG
bcf STATUS,
RP0 ;select bank 0
The three lowest bits of the Option register set the timing for the
WDT:
bsf STATUS, RP0 ;select
bank 1
movlw b'xxxxx000'
movwf OPTION_REG ;WDT timer = 18mS
or:
movlw b'xxxxx001'
movwf OPTION_REG ;WDT timer = 36mS
or:
movlw b'xxxxx010'
movwf OPTION_REG ;WDT timer = 72mS
etc etc
or:
movlw b'xxxxx111'
movwf OPTION_REG ;WDT timer = 2,304mS = 2.3
Seconds
bcf STATUS, RP0 ;select bank 0
GPIO CHANGE
If you want the micro to come out of sleep when the voltage-level
changes on any input line, the WDT must be turned off. This must be
done during burning the program into the chip. (You will not have
the advantage of the watchdog timer to reset the micro if it runs
off the end of the program.)
movlw b'xxxx1xxx'
; Enable GPIO port change interrupt (but NOT GIE)
movwf INTCON
Make at least one of the in-out pins an input:
bsf STATUS, RP0 ;select
bank 1
movlw b'xxxx1xxx' ;make GP3
input
movwf TRISIO
bcf STATUS, RP0 ;select
bank 0
Add the SLEEP instruction to the program:
goto sleep_micro
Add the SLEEP sub-routine:
sleep_micro
sleep
Alternately, a SLEEP instruction can be added to a program. In the program
below, the micro will stop executing instructions when it reaches "sleep"
and wait for a "time-out" of the WDT or a change in GPIO (depending on the
setting in INTCON.) If the GIE bit is set, the micro will execute
"instruction A" (after sleep) and go to
the interrupt address (004h).
instruction
instruction
instruction
sleep
instruction A - this instruction can be anything but a
GOTO instruction.
no further instructions
If you don't want an instruction after "sleep" use: NOP.
The Global Interrupt feature is enabled by setting
bit 7 of the INTCON register.
For this and other features of SLEEP see:
PIC12F629
Data Sheet (.pdf 4,926KB)
Another SLEEP
sub-routine:
To put the micro to sleep, a number of things must be done. This
routine allows the micro to go to SLEEP when it detects the SLEEP instruction.
The micro wakes up from sleep when it detects a change on GPIO,5 (pin 2).
Pin 2 must have a pull-up resistor for the following program to work. The
pull-up resistor can be external (about 47k) and a push switch to take the pin
low to take the micro out of SLEEP.
To turn on the weak internal 47k pull-up resistor, place the following
instructions in SetUp:
bsf STATUS,RP0
; Sel Bank 1
bcf OPTION_REG,NOT_GPPU
; enable weak pull-up
bsf WPU, 5
; enable wpu on GPIO 5 only
bsf IOC, 5
; enable Int-On-Change GPIO 5
bcf STATUS,RP0
; Sel Bank 0
Sleep
|
movf GPIO,W
bcf INTCON,GPIF
bsf STATUS,RP0
movlw 0xFF
movwf TRISIO
sleep
nop
movlw b'11101000'
movwf TRISIO
bcf STATUS,RP0
movf GPIO,W
bcf INTCON,GPIF
|
; Read GPIO clears Int-On-Change flag. Must read
; into W not back to F as it reads port not the output
; latch which may result in output data being
; inadvertently altered.
; Sel bank 1
; Setup W for TRISIO all input
; Write to TRISIO. Reduce power in sleep mode
; Go to sleep
;
; Wake from sleep and set
; TRISIO for input and output for your project
; Sel Bank 0
; Read GPIO register
; and clear GPIF flag in interrupt register |
|
Stack
This is an area where up to 8 addresses
are placed. These address are RETURN address. When a CALL is made,
the address of the next instruction in your program is placed on the STACK.
The micro will go to the sub-routine you have CALLed. In this sub-routine
you can have another CALL.
This is the second CALL. In the second sub-routine you can have another
CALL. In fact this can be done up to 8 times.
If more than 8 address
are placed on the stack, the first address is lost.
That's why you cannot have more than 8 CALLs. When a return
is made, the CALL number is reduced.
The PIC12F629 can have a CALL instruction that CALLs another
sub-routine and the sub-routine CALLs another sub-routine and that sub-routine
CALLS another sub-routine until 8 CALLs are made.
The 8th sub-routine will have a RETLW 00 to go back the the
previous sub-routine and each sub-routine will have a RETLW 00 until
finally the micro returns to Main.
The animation below shows a CALL in a sub-routine CALLing another
sub-routine and this sub-routine CALLs another sub-routine.
The Program Counter makes the micro carry out the
instructions.
Note: Return is used in '508 instruction-set and Retlw 00 is used in
'629 instruction-set):
The PIC12F508 or 509 has only a "2-stack" and the low-cost PIC micro
(reserved for high-quantity orders) has only a "2-stack." It
is important to realise this so your programs are portable to other
micro's. You can have a CALL from Main and a CALL from the
sub-routine, but the second sub-routine must only have a RETLW 00.
Stop
see
also Wait.
The microcontroller does not have a
Stop instruction. Do not use the word "Halt"
as a label, the assembler does not like it. Use Loop, Pause,
Wait. See Loop.
To create a "waiting loop" use the following instructions:
| Loop
|
NOP
GOTO Loop |
;Hold the micro in a loop |
|
When testing a program,
you may need to know if the microcontroller has advanced to a certain
part of the program.
Insert the instruction: GOTO Wait.
Insert the following instructions. They should include an output
to a LED etc so you can prove the micro has entered the loop.
| Wait
|
NOP
MOVLW 07h
MOVWF GPIO
GOTO Wait |
;Hold the micro in a loop
;Output a HIGH to LEDs |
|
Store
Data
The PIC12F629 has two ways to store data.
If you need to store only a few bytes of data for a short period
of time, use files that are not required in any of the running of
the program.
This information will be lost when power is removed.
If you want to store data permanently, the PIC12F629 has 128 bytes
of EEPROM.
This requires a special routine - found under EEPROM.
S ound
The following program produces a "rising Sound."
sound
sound1
sound2
sound3
|
movlw 0F0h
movwf temp
bsf GPIO,0
movf temp,0
movwf soundhigh
nop
nop
nop
nop
nop
decfsz soundhigh,1
goto sound2
bcf GPIO,0
movf temp,0
movwf soundlow
nop
nop
nop
nop
nop
decfsz soundlow,1
goto sound3
decfsz temp,1
goto sound1
retlw 00 |
;
;Piezo bit HIGH
;piezo bit LOW |
|
SWAP
PIC language has a SWAP NIBBLES instruction. It swaps the HIGH nibble
with the LOW nibble. Swapping INDF (file 00) actually swaps
the nibbles in the file pointed to by FSR.
| |
SWAPF 2A,1 |
;Before: File 2A
= 81h After: File 2A = 18h
|
|
SWAP
THE CONTENTS OF TWO FILES
Example: File 2C = 81h
File 2D = 47h
File 2E = temp storage
| |
MOVF 2C,0
MOVWF 2E,1
MOVWF 2D,0
MOVWF 20C,1
MOVF 2E,0
MOVWF 2D,1 |
;Move 2C to W
;Move W to 20E
;Move 2D to W
;Move W to 20C
;Move 2E to W
;Move W to 2D |
|
To swap the contents of two files without using a temporary file:
| |
movf X, w
subwf Y, w
addwf X, f
subwf Y, f |
|
|
Another way to swap the contents of two files without using a temporary file:
| |
movf
X, w
xorwf Y, f
xorwf Y,w
movwf X
xorwf Y, f |
; Get X
; Y is now X^Y
; W is now (X^y)^X==Y (say OldY)
; Now X is OldY
; finally Y is (OldX^Y)^Y==OldX |
|
SWAP
THE CONTENTS OF A FILE WITH W
Example: File 3C = 81h W = 47h
after operation: File 3C = 47h W = 81h
| |
XORWF
3C,1
XORWF
3C,0
XORWF
3C,1 |
|
|
Switch
(button, key)
see
also Poll
There is no difference between "Switch," "Button"
and "Key." They all refer to a push button that has
momentary action. It can be an individual push button, one of a number
of buttons or in a matrix of buttons such as a keypad.
With all button instructions, there are three important things to
remember. They are mechanical devices and their action is very slow
in "microprocessor-time." They produce a lot of pulses when
pushed and also when released (this is called switch-noise or switch-bounce).
In any button routine, you must also prevent a button-press being
registered more than once.
Many sub-routines already have a switch or button feature included
in them. Select an existing sub-routine or use the following.
The most important part of adding a switch or button routine is creating
the debounce feature.
This is to prevent "double-counting" when the button is
pushed or released. Try slow-pressing and slow-release to see if the
program produces a false result. If the program "double-counts,"
you will have to increase the debounce-time.
Debounce can take up a lot of computer-time. Debounce is a delay routine
that "masks" (hides - or disallows) the time when the button is pressed or released,
so that only one pulse is detected. Instead of producing a separate debounce routines, you may be able to use the time taken to execute
other sub-routines. In other words, the program looks before and
after the execution of another routine and if the button is still
pressed, the micro detects it as a "button-press."
Finally, you need to detect the first press of a button and prevent
the program operating on the button during the second pass of the
program.
The basis of detecting a button-press consists of 6 separate items
that must be placed in the following order:
There are two flags. Bit0 in file 1F is the Debounce Flag and
Bit1 in file 1F is the Button Pressed flag.
The microprocessor executes Main and CALLs Sw. If
Sw detects a key-press, two flags are SET. The first is the
Button Pressed flag and the second is the Debounce
flag.
The micro returns to Main and tests the Button Pressed
flag to see if it is SET. If is is SET, the micro goes to a
sub-routine such as CALL Increment, where a value can be
incremented. The Button Pressed
flag is then cleared and the micro CALLs Sw. If the switch is still
pressed, the micro will return. The program is looking for the
button to be released. When the button is released, the Sw
sub-routine is ready to detect another button-push.
SetUp
Sw
Sw1
Sw2
Main
Main2 |
BSF 03,5
MOVLW 01
MOVWF TRISIO
BCF 03,5
CLRF 2F
GOTO Main
BTFSS 05,0
GOTO Sw2
BTFSC 2F,0
RETLW 00
DECFSZ 2A,1
GOTO Sw1
BTFSS 05,0
GOTO Sw2
BSF 2F,1
BSF 2F,0
RETLW 00
BCF 2F,0
RETLW 00
CALL Sw
BTFSC 2F,1
GOTO Main2
Display the values on a display etc.
GOTO Main
CALL Increment
BCF 2F,1
GOTO Main |
;Go to Bank 1
;Put 01 into W
;Make GP0 input
;Go to Bank 0
;Clear the button-press file
;Test the button. Button is "Active HIGH"
;Button not pressed
;Button pressed first time? Test debounce flag
;Button already pressed.
Return to Main
;Create short delay
;Look again
;Is switch still pressed?
;It was only noise
;Button Pressed. Set button-pressed flag
;Set debounce flag
;Return to Main
;Clear debounce flag
;Return to Main
;Test button-press flag to see if button was pressed
;Button pressed
;Button not pressed
;Increment the display. (you provide the routine)
;Clear the button-press flag |
|
|