Same code in different Pins


Closed Thread
Results 1 to 32 of 32

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    This is another one of those examples where arrays act differently depending on whether a Constant or a Variable is used as the index.
    Using the same statement...
    owout pin.0[index], 1, ["data here"]
    If index is a Constant, it does what you thought, and will use the index to select the Pin as an offset from PORTA.0. So 8 would be PORTB.0. But then, you can't change it at run-time.
    IF index is a variable, then it makes it an Array operation that will read the value of the indexed Pin (0 or 1), that value then becomes the "PIN Number".
    When a statement works 2 different ways like that it's hard to grasp sometimes.
    Not sure why meLabs did things that way.
    <br>
    Might be the difference between a $250 compiler and a $2,500 compiler.
    But I got what you were getting at.

    I think the original post'ers only option is to do the SELECT CASE thing, combine all OWOUT's into one place, use a generic "data here" string type array variable and go with it.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I think the original post'ers only option is to do the SELECT CASE thing,
    Well, I think Josuetas' best option can be found in Post #4
    <br>
    DT

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Well, I think Josuetas' best option can be found in Post #4
    <br>
    True, but what if the pins are on PortA, or D, or E, or F, or G, or H, or J

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    True, but what if the pins are on PortA, or D, or E, or F, or G, or H, or J
    Then you would change the PORTL and or PORTH assignments in the .bas file for the chip you are using.

    PORTL and PORTH determine which ports are used for "Pin Numbers".
    PORTL is 0-7
    PORTH is 8-15
    <br>
    DT

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Then you would change the PORTL and or PORTH assignments in the .bas file for the chip you are using.

    PORTL and PORTH determine which ports are used for "Pin Numbers".
    PORTL is 0-7
    PORTH is 8-15
    <br>
    Are you talking about the .bas file in the PBP directory?
    I would've thought the compiler would go nuts if you changed anything in those .bas files... I know you can change the .inc files....hmm... interesting thoughts brewing in my head now...
    Thanks a lot...now I got more crap to think about!

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Yes, the .bas file in the PBP folder. ie. 16F877.BAS

    And, just like you do with the Config lines in the .inc file.
    You can comment out the PORTL/H and TRISL/H lines, which allows you to define them in your main program.

    Then you can...
    Code:
    PORTL   VAR     PORTA
    TRISL   VAR     TRISA
    PORTH   VAR     PORTD
    TRISH   VAR     TRISD
    Which puts 0-7 on PORTA, and 8-15 on PORTD.

    Or to whichever ports you wanted.
    DT

  7. #7
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Then you would change the PORTL and or PORTH assignments in the .bas file for the chip you are using.

    PORTL and PORTH determine which ports are used for "Pin Numbers".
    PORTL is 0-7
    PORTH is 8-15
    <br>
    Hi Darrel,

    I have looked in the .bas file for the 18F452 and located the following code
    Code:
    PORTL   VAR     PORTB
    PORTH   VAR     PORTC
    TRISL   VAR     TRISB
    TRISH   VAR     TRISC
    Would I be correct in assuming that you also have to "adjust" the TRISL and TRISH aliases as well?

    I take it that the ports dont have to be consecutive so that I could put

    Code:
    PORTL   VAR     PORTB
    PORTH   VAR     PORTD
    TRISL   VAR     TRISB
    TRISH   VAR     TRISD
    Which would give me 0-7 = PortB.0-PortB.7 and 8-15 = PortD.0-PortD.7

    If so that greatly simplifies something I am trying to impliment. The reason I want to change PORTH from C to D is that I need to use the USART which is on C6 and C7 so that would only give me 14 useable pins.


    DOH !!!!

    Thatll teach me not to make sure I have a newly refreshed view of a thread before I post a reply !!!!
    Last edited by keithdoxey; - 27th March 2007 at 20:37. Reason: Explaining why I look like a Dumba$$
    Keith

    www.diyha.co.uk
    www.kat5.tv

  8. #8
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Lightbulb

    I hate when that happens!

    At least everything you said was correct.
    Could have been worse.

    Hey Josuetas,
    Still with us?
    <br>
    DT

  9. #9


    Did you find this post helpful? Yes | No

    Default Hi, so many replies in hours!!!

    Thanks Darrel, yes i am here.... i wasnt but now i am....

    Well that is great that at least helps me reduce everything, bad thing is that i already made the PCB, i should get it by thursday... :P

    God thing is i Used Portb(ALL) and PortC(2Bits) and portD (2 bits), and PORTA (4bits) 16 1Wire devices.

    So i Guess by now i will use Darrel`s recomendation for all portb and change the .bas to use portb A, and maybe handle the rest of the bits with select case :'(.

    Darrel by the way.. How then do you use DEFINES to work with your include files? (i dont relly know if yours ), does this mean that once the defined is set one is supposed to stay with it and not change it?

    Thanks to all for your replies, I am still hoping something better could be done

    Bye

Similar Threads

  1. My code for TV remote and MIBAM for RGB control
    By idtat in forum Code Examples
    Replies: 4
    Last Post: - 12th January 2013, 20:52
  2. Nokia COLOR LCD PicBasicPro 2.50a example code
    By skimask in forum Code Examples
    Replies: 49
    Last Post: - 28th September 2011, 01:43
  3. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  4. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07
  5. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23

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