Stop program


Closed Thread
Results 1 to 3 of 3

Thread: Stop program

  1. #1
    Join Date
    Mar 2004
    Posts
    92

    Default Stop program

    Hi,

    I am trying to stop the main program when the 16F628A senses a momentary high on two inputs. I have tried a IF...Then loop and it has not achieved the needed result.

    I need to stop the main program dead in it's tracks,is using interrupts the way to go on this ?

    Thanks for any info
    Sam

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    > is using interrupts the way to go on this ?

    Not necessarily. You may be making life more complicated as you still have to work out what and how many pins have caused the interrupt. Remember that an interrupt isn't serviced until the current command has executed, so by the time you get to looking at the interrupt flag, you may miss the pulse on the next pin. If both pins are going to cause an interrupt, then the interrupt flags WON'T tell you that they happened simultaneously.

    You need to AND the two pulses together and then trigger an interrupt. This will work, but remember the delay between completion of the last command being executed and servicing the interrupt.

    If you use a PIC with comparators, and both pulses are the same level, then you can use those instead of any external AND gates. If the pulses are not the same level then you can still use the comparators but a little more magic is needed.

    Finally, if you want to stop your processor dead, IMMEDIATELY, then the AND gate (or Comparator) connected to the MCLR pin is the way to go...

  3. #3
    Join Date
    Mar 2004
    Posts
    92


    Did you find this post helpful? Yes | No

    Default

    Thank you Melanie,

    You provided the exact info I needed.I had thought about the MCLR but not using an AND to activate it. After reading your reply I used a PIC12F675 to perform the AND to trigger the MCLR on the 16F628. Works perfect !

    I guess a 12F675 may be overkill for a AND gate, but I needed the timing function of it to keep MCLR low for an extended period. I am not sure about using the same 16F628 as an AND as I am using several of the I/O as digital for the main program.

    Thanks again, your knowledge is appreciated,
    Sam

Similar Threads

  1. Presetting Configuration Fuses (PIC Defines) into your Program
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 82
    Last Post: - 15th December 2013, 09:54
  2. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  4. PIC16F684 Program question
    By Nicholas in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th December 2006, 14:30
  5. Debug in + Floating pin = stop program execution?
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 9th November 2005, 08:46

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts