External Interrupt in PIC16F877

Discussion in 'Embedded Systems and Microcontrollers' started by ecaits, Apr 3, 2014.

  1. ecaits

    Thread Starter Member

    Jan 6, 2014
    52
    0
    I have used 3 analog input (0-5V) through pin RA0, RA5 and RE0 (in terms of three parameter like pressure, TDS and Turbidity) and I am displaying output of ADC on LCD at interval of few second each in PIC16F877 using hi-tech compiler.

    Now during scrolling of parameter, I want to hold the current parameter by pressing one switch and by using another switch called Reset, I want to again scroll the parameter on LCD at interval of few second.

    I think that I have to use external interrupt but I dont know how to implement it.

    I have attached code for your reference.

    Plz suggest me that how can I implement the code.

    Waiting for your support,

    Thank you in advance.
     
    Last edited: Apr 3, 2014
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,605
    Using an interrupt to read a pin is not the way to go about things. Buttons actually work really badly for a computer to read: when pressed they give multiple changes, and a fast computer will see them all. It's switch bounce, and every switch has it.

    A button is best read (relatively) slowly: in my work I set up a button scan routine that looks at the buttons every 20 mS or so, and does no declare a button pressed until it reads the same thing twice in a row. That gets rid of the bounce.

    You can see if your main loop gives you enough delay to use to scan, or what I do is I dedicate a timer to give me 1mS interrupts so not only do I get a time reference (very useful for many things) but I also have it check the buttons and leave the result in a global variable.
     
  3. ecaits

    Thread Starter Member

    Jan 6, 2014
    52
    0
    Can you provide me some codes for reference purpose so that I can implement it.
     
  4. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Could you post your code. It could help to see what you have done. Something went wrong with your code attachment in your first post
     
  5. ecaits

    Thread Starter Member

    Jan 6, 2014
    52
    0
    I have attached my code.
    In this code, I want to implement the interrupt but i dont know how to implement it.

    Plz support.

    Thanks,

    Nirav
     
  6. ecaits

    Thread Starter Member

    Jan 6, 2014
    52
    0
    Dear All,

    To interface keypad in pic16f877, will I need to connect +Vcc with resistor to input port to detect the switched pressed???

    Can you give me logic of key detection???

    Thank you
     
Loading...