How to know what pin triggered an interrupt?


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    sheepdog's Avatar
    sheepdog Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xnihilo View Post
    Interesting, it would be fine if I was scanning from MSB to LSB, it is not the case.
    Pin0 is the head
    ...
    Pin4 is the right arm
    Default porta is %xx111111
    If Pin0 is activated we will have %xx111110
    Reversed it will be %xx000001

    It will tell me it is pin0, okay. What if there are two activated pins, example, reversed it would be %xx001001, it will tell me the activated pin is pin 3, which is true but as I have to scan starting from pin0, I will think the left arm was hit and use that info while the head was hit too, which is much worst (lethal) and the player will get some damage while a hit in the head would tag him out. See?
    Yes I see, be fine if head pin3, glad you have it all sorted out anyway

  2. #2
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Question

    Uh, seems that things are not so easy...

    This time I guess it is a hardware concern.

    I put a pin (c2) high somewhere before the routine that reads the incoming signal and put it low after, just to have a visual estimation of the time it takes to complete the routine.
    The pin is just a test pin that lights a 5V led.
    If I don't connect the led to the pin, then the signal is invalid but if I connect the led, all incoming signals are good...
    C2 is an output pin, default low (no external WPU or WPD resistor).
    If I connect the pin to GND through a 10K resistor, it is better but sometimes the signal is missed. Connecting the led ensures the signal is collected fine...

    It makes no sense.

    1 hour later:

    I noticed I left from previous test C0 as input, default high but not using an external WPU.
    I changed it back to output, default low.
    Still I would miss some signals.
    Then adding a 10K WPD instead of a led on the OUTPUT pin C2 seems to fix the problem.
    I wonder how a WPD on an OUTPUT pin acts on my code ???

Similar Threads

  1. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  2. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

Members who have read this thread : 0

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