Searching \ for '[PIC]: Changing RB0 INT edge trigger' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/devices.htm?key=pic
Search entire site for: 'Changing RB0 INT edge trigger'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Changing RB0 INT edge trigger'
2001\04\28@100501 by Graham North

picon face
Hi all,

Thanks for all the help with the interupt problms. I finally got them
working.
Guess I'll have to rember OPTION_REG is in Bank1! Doh!

I have just realised that I need the RB0 interupt to trigger on both edges!
So
I have decided to change the trigger edge on the fly. My question is:

       Is this the fastest/most efficient way to do this?

       BANK1

       btfsc   OPTION_REG,INTEDG       ; IF already set to +ve edge trigger
       goto    SET_NEG_EDGE            ; Goto set -ve dege trigger
       bsf     OPTION_REG,INTEDG       ; ELSE set +ve edge trigger
       goto    EDGE_SET                ; Finished

SET_NEG_EDGE

       bcf     OPTION_REG,INTEDG       ; Set -ve edge trigger

EDGE_SET                                ; Finished

       BANK0

I seem to remember being able to XOR a file with another to do someting. Is
that a way change just one bit. I could never get my head round it. Could
someone
explain the whole XOR thing.

Thanks

Graham
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\04\28@103446 by michael brown

flavicon
face
----- Original Message -----
From: "Graham North" <spam_OUTgs_piclistTakeThisOuTspamHOTMAIL.COM>
To: <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU>
Sent: Saturday, April 28, 2001 9:04 AM
Subject: [PIC]: Changing RB0 INT edge trigger


> Hi all,
>
> Thanks for all the help with the interupt problms. I finally got them
> working.
> Guess I'll have to rember OPTION_REG is in Bank1! Doh!

Been there, done that.  <GRIN>

> I have just realised that I need the RB0 interupt to trigger on both
edges!
> So
> I have decided to change the trigger edge on the fly. My question is:
>
>         Is this the fastest/most efficient way to do this?
>
>         BANK1
>
>         btfsc   OPTION_REG,INTEDG       ; IF already set to +ve edge
trigger
{Quote hidden}

Is
> that a way change just one bit. I could never get my head round it. Could
> someone
> explain the whole XOR thing.

Just like OR except 1(XOR)1 ->0   That's pretty much it.

    0  1
-----------
0 | 0  1
1 | 1  0

WARNING: Untested code ahead  ;-)  But this is the fastest way I know of.

           BANK1
           movlw          b'01000000'                load bit mask for
INTEDG (bit 6)
           xorwf            OPTION_REG, F        flip the bit, leaving
result in OPTION_REG
           BANK0

Of course you are left with no idea of which state the bit is currently in,
it just gets flipped.

{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\04\28@145108 by Bob Ammerman

picon face
> Hi all,
>
> Thanks for all the help with the interupt problms. I finally got them
> working.
> Guess I'll have to rember OPTION_REG is in Bank1! Doh!
>
> I have just realised that I need the RB0 interupt to trigger on both
edges!
> So
> I have decided to change the trigger edge on the fly. My question is:
>
>         Is this the fastest/most efficient way to do this?
>
>         BANK1
>
>         btfsc   OPTION_REG,INTEDG       ; IF already set to +ve edge
trigger
{Quote hidden}

Is
> that a way change just one bit. I could never get my head round it. Could
> someone
> explain the whole XOR thing.
>
> Thanks
>
> Graham

Yep, XOR is the trick. Try this:

   BANK1
   movlw    1 << INTEDG
   xorwf      OPTION_REG,F
   BANK0

The 'movlw 1 <<INTEDG' sets W to contain a 1 bit in the position
corresponding to the INTEDG bit in the OPTION_REG and zero bits everyplace
else.

The 'xorwf OPTION_REG,F' computes:

   OPTION_REG = OPTION_REG xor W

Now 'xor' is defined as follows:

0 xor 0 = 0
0 xor 1 = 1
1 xor 0 = 1
1 xor 1 = 0

Note that an xor with zero leaves a value unchanged, but an xor with one
complements it.

Bob Ammerman
RAm Systems
(contract development of high performance, high function, low-level
software)

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics



'[PIC]: Changing RB0 INT edge trigger'
2001\05\01@030659 by David Cary
flavicon
face
Dear Graham North,

Graham North <gs_piclistspamKILLspamHOTMAIL.COM> on 2001-04-28 09:04:35 AM mentioned:
> I have just realised that I need the RB0 interupt to trigger on both edges!
> So I have decided to change the trigger edge on the fly.

Michael Brown's code looks good at first glance.

On the 16F87x, RB4 and RB5 can be set up to "interrupt on change". Maybe it
would be simpler to use one of those rather than RB0 ?

--
David Cary

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...