- Name:
-
hintsetup
- Syntax:
-
HINTSETUP mask
Mask - is a variable/constant which defines which interrupt pins to activate.
| Bit 7 |
- reserved |
| Bit 6 |
- Interrupt 2 Trigger (1 = rising edge, 0 = falling edge) |
| Bit 5 |
- Interrupt 1 Trigger (1 = rising edge, 0 = falling edge) |
| Bit 4 |
- Interrupt 0 Trigger (1 = rising edge, 0 = falling edge) |
| Bit 3 |
- reserved |
| Bit 2 |
- Interrupt 2 Enable |
| Bit 1 |
- Interrupt 1 Enable |
| Bit 0 |
- Interrupt 0 Enable (not available on 20X2) |
- Description:
-
The X2 parts have up to 3 hardware interrupts pin (INT0, INT1, INT2) which are activated/deactivated by the hintsetup command. The hardware interrupt pins constantly background monitor for an edge based trigger. As they operate in the background the PICAXE program does not have to poll the input to detect a change in state.
The hardware interrupts are triggered and processed extremely quickly. Therefore be aware of, for instance, switch contact bounce, which may give unexpected results if not debounced by software and/or hardware.
The hardware interrupt pins can also wake a PICAXE microcontroller from sleep / doze mode.
The hardware interrupt pins cause an instant change in the hardware interrupt flags upon input pin condition change.. If a setintflags command has also been issued, a PICAXE program interrupt may then occur.
Activation of each individual pin sets two flags, its own unique flag and the shared 'hintflag'. The flags must be cleared manually in the user's PICAXE program. The hintsetup command enables the hardware setting of the flags only, it does not trigger an actual PICAXE program interrupt.
Therefore to have the PICAXE program call the "interrupt:" section of code upon a hardware pin interrupt you must follow two steps:
1) use hintsetup to allow hardware flag setting.
2) then use setintflags to actually generate an interrupt upon the setting of those flags. This means it is possible to interrupt on a combination of any, or all, of the flags via use of the setintflags command. See the setintflags command description for more details.