Thread: Help for interrupt using MicroC for Pic

  1. #1
    Registered User
    Join Date
    Nov 2013

    Help for interrupt using MicroC for Pic

    Sir ,
    I have a problems using interrupt in MicroC for PIC. Am using PIC 16F877A
    Sir e.g I have two square waves , when first wave rise interrupt 1 start and timer also start , after some time 2nd square wave rise at that time timer should be off , and the value of timer should be stored in a variable , this is the part of my project , please Help
    Regards Usman Ghani

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Well since that PIC has only one real interrupt line, the first thing you need to do is decide how you're going to get two inputs into the processor.

    Are you using some kind of dev-board, which comes with a range of LEDs, switches, maybe even an LCD display, and some serial/USB connection to your host computer?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jun 2011
    As Salem mentioned, there is only one direct hardware interrupt line on the PIC16F877A (*). This means that your first pulse sequence will have to trigger the interrupt and enable the timer. I suppose you would have to poll the input for the second pulse sequence to determine when it goes high - however, if your code is doing other work, this will likely throw off your timing measurement (the finite time it takes to reach the polling code).

    (*) It should also be noted that the PIC16F877A device does have four "interrupt-on-change" pins (PORTB 7:4), but whether or not this will be useful for you depends on the exact specifications of the assignment. It is strongly recommended by Microchip, when using this "interrupt-on-change" function, not to use that port for anything else, and to not poll that port. Considering the resulting interrupt flag is a wired-OR configuration, you will not automatically know which pin (and at what polarity) triggered the interrupt in the first place, so its usefulness for your application is questionable. Also note that there is a potential hardware bug with this function in a lot of devices (link).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with interrupt handler
    By afflictedd2 in forum C Programming
    Replies: 1
    Last Post: 02-17-2010, 03:47 PM
  2. ASM interrupt and others
    By Unregistered in forum A Brief History of
    Replies: 5
    Last Post: 06-08-2002, 07:18 PM
  3. interrupt
    By juandy in forum C++ Programming
    Replies: 4
    Last Post: 05-21-2002, 08:24 AM
  4. Interrupt???
    By GiSH in forum C++ Programming
    Replies: 1
    Last Post: 11-15-2001, 12:27 PM
  5. Calling ISR w/o interrupt
    By VirtualAce in forum A Brief History of
    Replies: 4
    Last Post: 11-02-2001, 05:29 PM