Go to last post By: Lester
Today 14:50
Forum: Website / Forum Issues
Starter: Lester
Views: 0
Replies: 16
Today 11:16
Forum: Proton Plus Compiler v3
Starter: Henk57
Views: 0
Replies: 9
Yesterday 22:55
Forum: USB
Starter: See_Mos
Views: 0
Replies: 4
+ Reply to Thread
Results 1 to 6 of 6

Thread: Alias port pins125 days old

  1. #1
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,271
    Thumbs Up
    Received: 24
    Given: 4
    Total Downloaded
    331.30 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.

  2. #2
    Developer Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,245
    Thumbs Up
    Received: 234
    Given: 87
    Total Downloaded
    1.50 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
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  3. #3
    Member Henk57's Avatar
    Join Date
    Jan 2014
    Posts
    211
    Thumbs Up
    Received: 12
    Given: 21
    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.

  4. #4
    Developer Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,245
    Thumbs Up
    Received: 234
    Given: 87
    Total Downloaded
    1.50 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
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  5. #5
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,271
    Thumbs Up
    Received: 24
    Given: 4
    Total Downloaded
    331.30 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

  6. #6
    Developer Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,245
    Thumbs Up
    Received: 234
    Given: 87
    Total Downloaded
    1.50 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.
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. Replies: 4
    Last Post: 2nd May 2016, 15:10
  2. Port pins changing - RFM12B
    By Dave-S in forum Proton Plus Compiler v3
    Replies: 0
    Last Post: 16th April 2013, 18:15
  3. Port Alias
    By crankshaft in forum Proton Plus Compiler v3
    Replies: 14
    Last Post: 12th January 2012, 09:52
  4. [SOLVED !] 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 since 5th December 2017, 17:45 : 0

Actions :  (Set Date)  (Clear 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