The following program blinks an LED and stops when an RB0/INT interrupt
occurs.

This can be simulated by a push to on switch connected RB0 to Vcc and 10K
resistor from RB0 to ground.


-- ------------------------------------------------------
-- Title: Blink-a-led with stop on INT demo
--
-- Author: Sunish Issac, Copyright (c) 2008..2012, all rights reserved.
--
-- Adapted-by:
--
--
-- Compiler: 2.4o
--
-- This file is part of jallib  (http://jallib.googlecode.com)
-- Released under the BSD license (
http://www.opensource.org/licenses/bsd-license.php)
--
-- Description:
-- This program blinks an led on pin a0 and stops the blink on a high pulse
on interrupt
-- pin 6 with is RB0/INT on 16f88
--
include 16f88                    -- target PICmicro
--
pragma target clock 8_000_000     -- oscillator frequency
-- configuration memory settings (fuses)
pragma target OSC    INTOSC_NOCLKOUT -- internal osc
pragma target WDT      disabled     -- no watchdog
pragma target DEBUG    disabled     -- no debugging
pragma target LVP      disabled     -- no Low Voltage Programming
pragma target MCLR     Internal     -- reset internal

OSCCON_IRCF = 0b111                -- use 8 MHz internal oscillator

enable_digital_io()                -- make all pins digital I/O
--
--
alias   led      is pin_A0
pin_A0_direction =  output
--
var bit stopblink = false

procedure int_on_change_isr() is
   pragma interrupt
if  INTCON_INTF then
 stopblink = true     ; can be true only in isr
 INTCON_INTF = false
end if

end procedure


INTCON_GIE  = TRUE        -- Enables all unmasked interrupts
INTCON_INTE = TRUE        -- enable INT0 PIN for interrupts
OPTION_REG_INTEDG = 1     -- rising edge

forever loop
  if ! stopblink then ;make led on only while stopblink bit is false
     led = on
  end if
   _usec_delay(250_000)
   led = off
   _usec_delay(250_000)

end loop

Sunish

On Mon, Mar 5, 2012 at 5:56 PM, John in WI <[email protected]> wrote:

> Hi,
> I've been searching for a good explanation of how the JAL interrupts work.
> Every explanation I have found has left me more confused than when I
> started. I have looked at everything my internet searches bring up & the
> user manuals.
>
> My goal is to have a switch that will stop anything that is currently
> occurring. For instance, an LED is blinking. I push the button(at any time)
> and it will stop.
> I would also like to use interrupts to read a simple wheel encoder.
>
> A beginner lever example of using interrupts would be very helpful to me.
>
> Thanks very much! this group is great.
>
> --
> You received this message because you are subscribed to the Google Groups
> "jallib" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/jallib/-/n4eE86_dF6oJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/jallib?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en.

Reply via email to