PIC16F628A input question


Closed Thread
Results 1 to 5 of 5
  1. #1
    yankee's Avatar
    yankee Guest

    Question PIC16F628A input question

    Is it possible to have the PIC working on one operation due to an input from a toggle switch, then have another toggle switch input immediately interupt the first operation and perform a second operation, taking precedence over any other operation? I would need both operations to work independently of one another.

    Example:

    Switch1 on porta.0 = 0 then operation 1

    Switch2 on porta.1 = 0 then stops operation 1 before it finishes and over rides with operation 2

    Maybe I'll have to use another PIC in the circuit to stop the first PIC?

  2. #2
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Yankee and Happy New Years to all!

    Yes you can do what you want to do but you are not going to get Port A inputs to work in the manner you are requesting. Your regular input (the one with the least priority) can be a PortA input but if you want to interrupt it with more priority then you will need to use PortB.0 for that one.

    I personally have not done interupts myself yet but there are enough posts on this forum that will provide you with what you are looking for. Just goto the search and enter "Interupts" and you will find what you need.

    Have fun!

    BobK

  3. #3
    yankee's Avatar
    yankee Guest


    Did you find this post helpful? Yes | No

    Question Interupts

    Hi Bob, thanks for the reply. I searched and could find nothing that I was able to understand. Can someone provide a little help?

    Thanks in advance! ~ Dave

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Hi Yankee. You can do it simply with your code. The following assumes porta is held high and your input switches have common negative. Portb.0 controls operation1. Portb.1 controls operation2.

    START:
    LOW PORTB.0 'cancel operation1
    LOW PORTB.1 'cancel operation2
    IF PORTA.0 = 0 THEN OPERATION1 'ignore switch #2 but if #1 switch on do operation1
    GOTO START

    OPERATION1:
    IF PORTA.0 = 1 AND PORTA.1 = 1 THEN START 'both switches off cancel both operations
    HIGH PORTB.0 'do operation 1
    IF PORTA.1 = 0 THEN OPERATION2 '#2 switch on do operation2
    GOTO OPERATION1

    OPERATION2:
    LOW PORTB.0 'cancel operation1
    HIGH PORTB.1 'start operation2
    IF PORTA.1 = 0 THEN OPERATION2 'ignore #1 switch & stay here if #2 switch on
    GOTO START 'switch #2 off go home

  5. #5
    yankee's Avatar
    yankee Guest


    Did you find this post helpful? Yes | No

    Default

    OK, I'll try that out!

    I'll tell you what, it isn't easy going from strictly analog for 25 years to digital. Maybe this old dog can learn some new tricks.

    Thanks!

Similar Threads

  1. Replies: 8
    Last Post: - 22nd July 2008, 20:31
  2. Question from New member A/D input 16f876
    By mbruno in forum General
    Replies: 2
    Last Post: - 26th January 2008, 14:52
  3. Remote PIC input question
    By Adrian in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st September 2007, 15:44
  4. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 01:50
  5. input command (newbie question)
    By kctan in forum mel PIC BASIC
    Replies: 2
    Last Post: - 24th November 2005, 06:20

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