Alias port pins


+ Reply to Thread
Results 1 to 6 of 6

Thread: Alias port pins831 days old

  1. #1
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,326
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    802.58 MB

    0 Not allowed!

    Default Alias port pins

    Hi,
    Hopefully the title explains it, what I am tring to do is check the state of each pin of a port using a loop, it is probably possibe but I figure I have the syntax wrong or something.

    Code:
        While  CI_Loop < 8          ' Check pins 0 - 7 sequentially
        If PORTB.CI_Loop = 1 Then
            GroundPin = CI_Loop
            PinDetected = 1
            EndIf
            Inc CI_Loop
            wend
    CI_Loop is a byte variable and I have set all the input pins to inputs.

    I get Error, invalid cast for this type of variable.

    Does anyone know what I am doing wrong or a simple way to do it, I could simply do a series of If/Then statements but thought I would try to be cleverer than that.

    Regards,
    Bob
    Last edited by RGV250; 12th August 2017 at 14:38.

Attention

This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

The advertisements we display are relevant to this web site and your browsing history

Please consider supporting us by disabling your ad blocker.


Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

If you can, please report issues in the forum area WebSite / Forum Issues


Thank you for your attention.

  • #2
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,404
    Thumbs Up
    Received: 290
    Given: 141
    Total Downloaded
    1.68 GB

    0 Not allowed!

    Default Re: Alias port pins

    You can't, and never have been able to, use a variable as a bit number on a variable. That's why the compiler is giving the invalid alias error message.

    That's the purpose of the GetBit, SetBit, and LoadBit commands.

    Your routine should be:

    Code:
        While CI_Loop < 8          ' Check pins 0 - 7 sequentially
            If GetBit  PORTB ,CI_Loop = 1 Then 
                GroundPin = CI_Loop
                PinDetected = 1
            EndIf
            Inc CI_Loop
        Wend

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #3
    Senior Member Henk57's Avatar
    Join Date
    Jan 2014
    Posts
    406
    Thumbs Up
    Received: 19
    Given: 35
    Total Downloaded
    192.60 MB

    0 Not allowed!

    Default Re: Alias port pins

    Maybe an ReadPin command would help, but it doesn't exist yet.
    But would be usefull next to ClearPin en SetPin.

    The only thing I can say is, read PORTB into a Var. and place the Var. inside the CI_Loop.

    Henk.


    @Les already replyed.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #4
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,404
    Thumbs Up
    Received: 290
    Given: 141
    Total Downloaded
    1.68 GB

    0 Not allowed!

    Default Re: Alias port pins

    That's what GetBit does because a PORT is simply a variable to the compiler, there is a newer GetPin command that uses alias values for the pin numbers. See the manual.

    MyVar = GetPin 1

    or
    Dim PinValue as Byte

    MyVar = GetPin PinValue

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #5
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,326
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    802.58 MB

    0 Not allowed!

    Default Re: Alias port pins

    Hi Les,
    Fantastic support as normal.

    Funny story.

    I have been told I might be moved to StThomas Tuesday.
    Nurse doing her rounds asked if I had any bowel movement's today and I said no.
    Later on I had a little bout of laughing which set the monitor alarming, she reset the alarm and asked what the problem was.
    I said, that question you asked earlier, wait until next Tuesday and there will be plenty of them then.

    Bob

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  • #6
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,404
    Thumbs Up
    Received: 290
    Given: 141
    Total Downloaded
    1.68 GB

    0 Not allowed!

    Default Re: Alias port pins

    You're very welcome Bob.

    Don't worry mate, I was moved to a couple of hospitals, and one is exactly the same as the other. Full of miserable nurses, and overpaid doctors and consultants. LOL

    You get yourself better, that's the most important thing.

  • Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

    Thread Information

    Users Browsing this Thread

    There are currently 1 users browsing this thread. (0 members and 1 guests)

       

    Similar Threads

    1. Remapping port pins and 16 bit port
      By RGV250 in forum Proton Plus Compiler v3
      Replies: 7
      Last Post: 5th January 2018, 19:35
    2. Replies: 4
      Last Post: 2nd May 2016, 15:10
    3. Port Alias
      By crankshaft in forum Proton Plus Compiler v3
      Replies: 14
      Last Post: 12th January 2012, 09:52
    4. Alpha LCD Port pins
      By Jamil in forum Proton Plus Compiler v3
      Replies: 2
      Last Post: 7th March 2008, 00:36

    Members who have read this thread : 21

    Actions :  (Set Date)

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

    Tags for this Thread

    Posting Permissions

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