how to loop thru setting port bits?


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262

    Default how to loop thru setting port bits?

    I have a variable array, now I need to cycle thru it and set PORTB bits based on values in that array, heres my code

    Code:
    FOR CNT = 0 to 7
    IF TEMP[CNT] < 100 then PORTB.CNT = 0
    IF TEMP[CNT] >= 100 then PORTB.CNT = 1
    NEXT CNT
    Now "TEMP[CNT]" works fine, but it throws an error on "PORTB.CNT"

    Error is Bad Variable Modifyer ".CNT"

    I Changed it to PORTB.(CNT)

    New Error, Bad Token "."

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: how to loop thru setting port bits?

    Hi,
    Try
    Code:
    IF TEMP[CNT] < 100 then PORTB.0(CNT) = 0
    For more info see Melanies excellent write up and the follow up discussions.

    /Henrik.

  3. #3
    Join Date
    Dec 2012
    Location
    Tennessee
    Posts
    262


    Did you find this post helpful? Yes | No

    Default Re: how to loop thru setting port bits?

    ok i didnt get a error on compile but i cant test it yet as Ive got alot more code to finish. but no errors looks good so far.

Similar Threads

  1. Configuation bits setting in PBP
    By Max_Gauss in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th September 2010, 18:25
  2. Setting bits
    By bearpawz in forum General
    Replies: 9
    Last Post: - 28th November 2009, 00:37
  3. How to reference variable bits in a loop
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st April 2006, 15:56
  4. Addressing bits in a loop?
    By Mad_Labs in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th September 2005, 18:11
  5. Trouble setting config. bits
    By jswayze in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 13th March 2004, 22:22

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