Access pin using index


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Mar 2005
    Location
    Denmark
    Posts
    31


    Did you find this post helpful? Yes | No

    Default

    I am not really sure that I understand your question.

    I assume that you have an change on PORTA interrupt and that you want to know which of PORTA pins that triggered your interrupt.

    Maybe you could as the first thing in your interrupt handler read the lower 5 bits of PORTA to see there status.

    If I remember it right (don't have my manual here at work)
    You can isolate the lower 5 bits and put them into a variable

    Code:
    youvar = PORTA & $1f    ' put lower 5 bits of PORTA into youvar
    Then if PORTA.3 is low and the others are high you will get the value 23 in youvar

    Hope I remember it right
    *Let's do it*

  2. #2
    Join Date
    Aug 2005
    Posts
    57


    Did you find this post helpful? Yes | No

    Default

    I believe this document was off this forum.It describes indexing port bits.
    Attached Files Attached Files

  3. #3
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Sharky View Post
    I am not really sure that I understand your question.

    I assume that you have an change on PORTA interrupt and that you want to know which of PORTA pins that triggered your interrupt.

    Maybe you could as the first thing in your interrupt handler read the lower 5 bits of PORTA to see there status.

    If I remember it right (don't have my manual here at work)
    You can isolate the lower 5 bits and put them into a variable

    Code:
    youvar = PORTA & $1f    ' put lower 5 bits of PORTA into youvar
    Then if PORTA.3 is low and the others are high you will get the value 23 in youvar

    Hope I remember it right
    No, I know what pin triggered the int. I jut can write a routine that will read the incoming data on the specific pin as I don't know at the time I write he routine what pin it will be so I have to use an index but there is no way I can make it work.

  4. #4
    sinoteq's Avatar
    sinoteq Guest


    Did you find this post helpful? Yes | No

    Default Using index and pins

    Hi
    Indexing pins is not a totally safe thing to do with PBP. This is a "Extra feature" and works really great with some commands and not at all with others. I have had some really strange results using indexed pins and Pulsin. It would not be a big surprise if While was a no-no.

    One other thing, please forgive me if I am wrong, are you sure you are using Interupt? When I look at your code. Unless it is in the interupt handler I would say you are polling the pin to get the status and generate a "software interupt". IF this is the case there are more efficient ways to do that is much faster and will save a ton of codespace.

    if (porta.0 == 0) THEN
    pin = 0 'set the number of the pin for the score managment (update_scores)
    GOTO got_pin 'bypass
    ENDIF

  5. #5
    sheepdog's Avatar
    sheepdog Guest


    Did you find this post helpful? Yes | No

    Default

    Will it work via a pointer
    SYMBOL PORT_PIN = PORTA

    while PORT_PIN.0[pin] = 0
    Worth a try I guess, unable to test.

    or a loop of
    mybyte = portA
    while mybyte.0(pin) = 0

    By the way re: "You are right, bit shuffling and time wasting"
    MOVE?BB PORTA, _B0
    AND?BCB _B1, 00Fh, _B1
    NCD?BB _B1, _B0
    LABEL?L L00002

    END
    thats the size of the code in assembly using ncd added the "and" to remove msb
    Last edited by sheepdog; - 9th October 2008 at 19:48. Reason: code shuffle

  6. #6
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sinoteq View Post
    Hi
    Indexing pins is not a totally safe thing to do with PBP. This is a "Extra feature" and works really great with some commands and not at all with others. I have had some really strange results using indexed pins and Pulsin. It would not be a big surprise if While was a no-no.

    One other thing, please forgive me if I am wrong, are you sure you are using Interupt? When I look at your code. Unless it is in the interupt handler I would say you are polling the pin to get the status and generate a "software interupt". IF this is the case there are more efficient ways to do that is much faster and will save a ton of codespace.

    if (porta.0 == 0) THEN
    pin = 0 'set the number of the pin for the score managment (update_scores)
    GOTO got_pin 'bypass
    ENDIF
    Yes, I am using interrupts on PORTA.

Similar Threads

  1. Is this a K Type sensor?
    By jessey in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 21st November 2009, 13:55
  2. DS1820 with 16f688
    By jessey in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 23rd May 2009, 05:07
  3. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 17:11
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17: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