• AVR Freaks

Hot!RISING EDGE GPIO INTERRUPT

Author
iamnaveen685
Starting Member
  • Total Posts : 56
  • Reward points : 0
  • Joined: 2018/09/18 07:44:02
  • Location: 0
  • Status: offline
2019/06/19 23:23:52 (permalink)
0

RISING EDGE GPIO INTERRUPT

Hi,
 
I am trying to develop a GPIO change interrupt, here I need interrupt only for the rising edge but I am getting interrupt for both falling edge
/* PORTK Initialization */
    CNPUKbits.CNPUK4=1; /* Pull-Up Enable */
    CNPUKbits.CNPUK5=1;
    /* Change Notice Enable */
    //CNCONKSET = _CNCONK_ON_MASK;
     /* Change Notice Enable */
    CNCONKbits.ON = 1;
    CNCONKbits.EDGEDETECT = 1;
    CNNEKbits.CNNEK4 = 1; //Falling edge
    CNENKbits.CNIEK4 = 0; //Rising EDGE DETECTION
    PORTK;
    IEC3bits.CNKIE = 1;
as well as rising edge,
 
I have added my code for initialization
#1

5 Replies Related Threads

    iamnaveen685
    Starting Member
    • Total Posts : 56
    • Reward points : 0
    • Joined: 2018/09/18 07:44:02
    • Location: 0
    • Status: offline
    Re: RISING EDGE GPIO INTERRUPT 2019/07/16 04:34:57 (permalink)
    0
    Can someone check this?
    #2
    ric
    Super Member
    • Total Posts : 22662
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: RISING EDGE GPIO INTERRUPT 2019/07/16 04:41:52 (permalink)
    0
    How are you testing this?
    i.e. what is generating the edges?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #3
    iamnaveen685
    Starting Member
    • Total Posts : 56
    • Reward points : 0
    • Joined: 2018/09/18 07:44:02
    • Location: 0
    • Status: offline
    Re: RISING EDGE GPIO INTERRUPT 2019/07/16 04:57:09 (permalink)
    0
    I am using a Switch  as an input and here i need interrupt only for Rising edge,but i am getting inteerupt whenever i press the button and release button, 
     
    how to configure only for the rising edge?
    #4
    KTrenholm
    Super Member
    • Total Posts : 709
    • Reward points : 0
    • Joined: 2012/08/08 14:04:23
    • Location: Connecticut, USA
    • Status: offline
    Re: RISING EDGE GPIO INTERRUPT 2019/07/16 08:22:57 (permalink)
    5 (1)
    Is your pushbutton switch debounced at all?  Maybe you're getting multiple edges per-press.
    #5
    ric
    Super Member
    • Total Posts : 22662
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: RISING EDGE GPIO INTERRUPT 2019/07/16 13:14:57 (permalink)
    0
    iamnaveen685
    I am using a Switch  as an input and here i need interrupt only for Rising edge,but i am getting inteerupt whenever i press the button and release button, 

    As I guessed. You are getting "switch bounce", i.e. multiple rising and falling edges on every change.
     

    how to configure only for the rising edge?

    Fix your hardware. Add an RC filter or some sort of hardware debounce circuit to the switch.
    Is reading the switch your final aim, or is that just to test it for your real input?
    If all you want to do is read a switch, then "change interrupt" is a bad way to do it.

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    Jump to:
    © 2019 APG vNext Commercial Version 4.5