Searching \ for 'Interrupt on change on PORTB' 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/ints.htm?key=interrupt
Search entire site for: 'Interrupt on change on PORTB'.

Truncated match.
PICList Thread
'Interrupt on change on PORTB'
2000\03\16@013339 by masubramanian

flavicon
face
Hello friends,
    Suppose I initialize PortB (RB4) as interrupt on change, and I need to
be interrupted on every rising edge only and during my high to low
transition, I should not get interrupted.  I am using limit switch as an
interrupt source.  But my program behaves erratically during emulation.
What could be the reason.  MPLAB simulation is perfectly ok.

thanks
rams

2000\03\16@043824 by Brent Brown

picon face
> Hello friends,
>      Suppose I initialize PortB (RB4) as interrupt on change, and I need to
> be interrupted on every rising edge only and during my high to low
> transition, I should not get interrupted.  I am using limit switch as an
> interrupt source.  But my program behaves erratically during emulation.
> What could be the reason.  MPLAB simulation is perfectly ok.
>
> thanks
> rams
>

Probably switch contact bounce. Switches do not open and close
like the text books say. Is your software behaving like it sees many
contact closures/openings instead of just one? Normal practice is
to write a software debounce routine that rejects rapid input
changes of less than say 20-30ms duration. Hardware debounce
circuits are also possible but it is usually preferable to do it in
software which is more flexible and does not require extra
components.


Brent Brown
Electronic Design Solutions
16 English Street
Hamilton, New Zealand
Ph/fax: +64 7 849 0069
Mobile: 025 334 069
eMail:  spam_OUTbrent.brownTakeThisOuTspamclear.net.nz

2000\03\16@070731 by Andrew Warren

face
flavicon
face
: S.Ramasubramanian <.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU> wrote:

> I initialize PortB (RB4) as interrupt on change .... my program
> behaves erratically during emulation [but] MPLAB simulation is
> perfectly ok.

Rams:

As Brent Brown suggested, it could be switch bounce.  It's equally
likely, though, that the erratic behavior is due to a known bug in
the interrupt-on-change circuitry within the PIC. For details, see my
web page:

   http://home.netcom.com/~fastfwd/answers.html#PIC00088

-Andy


=== Andrew Warren - fastfwdspamKILLspamix.netcom.com
=== Fast Forward Engineering - San Diego, California
=== http://www.geocities.com/SiliconValley/2499

2000\03\16@213226 by Gennette Bruce

flavicon
face
Most likely it is contact bounce.  You could use software or hardware
debouncing, but in this case I suggest using common sense logic-

On first detecting the Lo-Hi transition switch off interrupts,
then do whatever has to be done at the limit switch position,
then do a brute force (small) move away from the limit switch,
then turn interrupts back on.

All switch bounces occur while your routine is ignoring interrupts.  This
assumes you are controlling whatever is hitting the limit switch, if some
outside force is involved then you may need to think of something else.
But I think just ignoring the Hi-Lo-Hi-Lo bouncing as the switch is released
will be the simplest solution.

Bye.

       {Original Message removed}

2000\03\17@031234 by masubramanian

flavicon
face
Hi Bruce,
The same idea strike my mind and I disabled the interrupts and after doing
other routine, I am turning on the interrupts.
This works fine ICEPIC  for a while.  But suddenly it comes out and the
program points to ISR and stops.
In single step and animate mode, the program works as intended.  But when I
run, it works for a while and abruptly stops.
what can cause abrupt stopping of emulator.



rams
    LIST P=16C74B
    include "P16C74B.inc"


degree    equ  0xff
degree1 equ    0x90

         cblock    0x30
countb
temp
std
std1
counter
store
Back
flag
flag1
rstd
rstd1
pflag

         endc
;**********************************************

    org  0x00

    goto      begin
    org  0x04
    call ISR

    return


;**********************************************

begin
    clrf      rstd
    clrf rstd1
    clrf flag1
    clrf pflag
    call IBPORT
loop2
    btfsc     PORTA,0             ;Check for footswitch pressed
    goto      loop2
chk1 btfss     PORTA,0
    goto      chk1
    call regular
consr     call repeat
    goto      consr


ISR

    bcf  INTCON,RBIE
clr1 bcf  INTCON,RBIF
    btfsc     INTCON,RBIF
    goto      clr1
    bcf  INTCON,GIE
    bcf  INTCON,INTF
    goto      recon               ;Here in recon, I am reconfiguring PORTB
RB4 as o/p

    return

;regular routine and go back to normal opn

regular
    btfsc     rstd,7
    call dpinit
    btfsc     rstd1,0
    call cpinit
    btfsc     pflag,0
    goto droutine

croutine

    clrf pflag
    clrf      PORTB
    clrf PORTD
    incf countb,1
    movf countb,0
    movwf     temp
    bcf  STATUS,C
    movf std,0
    movwf     rstd
dec  decfsz temp,1
         goto      rot
    movf rstd,0
    movwf     PORTC
    btfss     rstd,7
    return
    clrf countb         ;clear countb after 8 rotations
    incf countb,1
    bsf  pflag,0        ;set pflag to do o/p to PORT D
    return
rot
    rlf  rstd,1
    goto dec


droutine
    bsf  pflag,0
    clrf      PORTB
    clrf      PORTC
    incf countb,1
    movf countb,0
    movwf     temp
    bcf  STATUS,C
    movf std1,0
    movwf     rstd1
decd decfsz temp,1
       goto   rotd
    movf rstd1,0
    movwf     PORTD
    btfss     rstd1,0
    return
    clrf countb         ;clear countb after 8 rotations
    incf countb,1
    bcf  pflag,0        ;set pflag to do o/p to PORT D
    return
rotd
    rrf  rstd1,1
    goto decd





IBPORT    bsf  STATUS,RP0
    movlw     0x00
    movwf     TRISB
    bcf  STATUS,RP0
    bcf  flag,0
    call      IPORT
    movlw     0x01      ;Initialize count
    movwf     countb
    movwf     temp
    movlw     B'00000001'
    movwf     PORTC
    movwf     std
    movlw     B'10000000'
    movwf     std1
    return
IPORT     bsf  STATUS,RP0          ;Switching to bank1

    movlw     0x03                ;PORTA, RA0 is used for switch input
    movwf   TRISA
    movlw     0xff
    movwf     ADCON1
    clrf      TRISC               ;Initializing Portc for output
    clrf TRISD               ;Initializing PortD for output
    bcf  STATUS,RP0          ;Switching to bank0
    clrf      PORTB
    clrf PORTC
    clrf PORTD
    return
reinit
    btfsc     PORTA,1        ;Check whether sense sw is still high
    return
    bsf  flag1,0
    bsf  STATUS,RP0
    movlw     0x10
    movwf     TRISB
    bcf  STATUS,RP0
    bcf  INTCON,RBIE
    bcf  INTCON,GIE
clr2 bcf  INTCON,RBIF
    btfsc     INTCON,RBIF
    goto      clr2
    bsf  INTCON,RBIE
    bsf  INTCON,GIE
    return

dpinit    clrf      PORTC
    movlw     B'10000000'
    movwf     PORTD
    clrf rstd
    return
cpinit    clrf PORTD
    movlw     B'00000001'
    movwf     PORTC
    clrf rstd1
    return

repeat
*****************************************************************************
;other    code


    bcf  flag1,0

    btfss     PORTA,1
    call reinit
    goto repeat

recon     bsf  STATUS,RP0
    movlw     0x00
    movwf     TRISB
    bcf  STATUS,RP0
    goto loop2
    return
;
*******************************************************************************************
    end




                   Gennette Bruce
                   <bruce.gennette@TAFE.N        To:     .....PICLISTKILLspamspam.....MITVMA.MIT.EDU
                   SW.EDU.AU>                    cc:
                   Sent by: pic                  Subject:     Re: Interrupt on change on PORTB
                   microcontroller
                   discussion list
                   <EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.ED
                   U>


                   03/17/00 08:01 AM
                   Please respond to pic
                   microcontroller
                   discussion list






Most likely it is contact bounce.  You could use software or hardware
debouncing, but in this case I suggest using common sense logic-

On first detecting the Lo-Hi transition switch off interrupts,
then do whatever has to be done at the limit switch position,
then do a brute force (small) move away from the limit switch,
then turn interrupts back on.

All switch bounces occur while your routine is ignoring interrupts.  This
assumes you are controlling whatever is hitting the limit switch, if some
outside force is involved then you may need to think of something else.
But I think just ignoring the Hi-Lo-Hi-Lo bouncing as the switch is
released
will be the simplest solution.

Bye.

       {Original Message removed}

2000\03\17@183502 by Soren Knudsen

picon face
>
> > I initialize PortB (RB4) as interrupt on change .... my program
> > behaves erratically during emulation [but] MPLAB simulation is
> > perfectly ok.
>
> Rams:
>
> As Brent Brown suggested, it could be switch bounce.  It's equally
> likely, though, that the erratic behavior is due to a known bug in
> the interrupt-on-change circuitry within the PIC. For details, see my
> web page:

This thing doesnt apply to RB0 INT too does it?

Soren Knudsen

2000\03\17@204440 by Andrew Warren

face
flavicon
face
I wrote:

> the erratic behavior [of Rams's code may be] due to a known bug in
> the interrupt-on-change circuitry within the PIC.

and Soren Knudsen <PICLISTspamspam_OUTMITVMA.MIT.EDU> replied:

> This thing doesnt apply to RB0 INT too does it?

   No, it doesn't.

   -Andy


=== Andrew Warren - @spam@fastfwdKILLspamspamix.netcom.com
=== Fast Forward Engineering - San Diego, California
=== http://www.geocities.com/SiliconValley/2499

2000\03\18@110817 by Alan Pearce

face picon face
>This thing doesnt apply to RB0 INT too does it?

It would apply to any interrupt derived from a mechanical switch. Any reed relay
contact, push button, ordinary relay, keyboard push button, you name it, it will
have contact bounce. Some types are worse than others for amount of bounce, and
length of time that they bounce.

In short, if you are using a mechanical contact to generate an interrupt, if you
have no external means of counteracting the bounce, you will need to take care
of it somehow in software.

2000\03\21@031827 by masubramanian

flavicon
face
Hello friends,
    Suppose I initialize PortB (RB4) as interrupt on change, and I need to
be interrupted on every rising edge only and during my high to low
transition, I should not get interrupted.  I am using limit switch as an
interrupt source.  But my program behaves erratically during emulation.
What could be the reason.  MPLAB simulation is perfectly ok.

thanks
rams

2000\03\21@032658 by douglas.burkett

flavicon
face
Switch bounce?

----- Original Message -----
From: ": S.Ramasubramanian" <KILLspamsr.ramasubramanianKILLspamspamUBG.TVSE.CO.IN>
To: <RemoveMEPICLISTTakeThisOuTspamMITVMA.MIT.EDU>
Sent: Thursday, March 16, 2000 6:42 AM
Subject: Interrupt on change on PORTB


> Hello friends,
>      Suppose I initialize PortB (RB4) as interrupt on change, and I need
to
> be interrupted on every rising edge only and during my high to low
> transition, I should not get interrupted.  I am using limit switch as an
> interrupt source.  But my program behaves erratically during emulation.
> What could be the reason.  MPLAB simulation is perfectly ok.
>
> thanks
> rams

2000\03\21@063035 by mike

flavicon
face
On Thu, 16 Mar 2000 11:12:10 +0530, you wrote:

>Hello friends,
>     Suppose I initialize PortB (RB4) as interrupt on change, and I need to
>be interrupted on every rising edge only and during my high to low
>transition, I should not get interrupted.  I am using limit switch as an
>interrupt source.  But my program behaves erratically during emulation.
>What could be the reason.  MPLAB simulation is perfectly ok.
>
>thanks
>rams
contact bounce?

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