undocumented code


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Yes.

    If you use the following, then each pin on portC will stay high.
    Code:
    main:
        for i = 0 to 7
          myArray.0[i]= 1
        next
        goto main
    All you are doing with myArray var PORTC is creating an alias or another name for portC. This does NOT create a normal variable using RAM. It only creates another name or alias to portC that is used only at compile time. Each reference to myArray will reference portC.

    Using myArray.0[i] just indexes individual bits or pins on portC. The .0 after the name just tells PBP it's a bit index.

    You would get the same result with something like;
    Code:
    main:
        for i = 0 to 7
          PORTC.0[i]= 1 ' <-- make PORTC.Bit i high
        next
        goto main
    The method mentioned above by Hans will work also. However, just which pins this will work on is dependent on the PIC you're compiling for.

    You have to be careful with this method of array.bit indexing (or any other array) since PBP does perform bounds checking.

    I.E. if you have an array (myArray) limited to 16-bits in size, it would hold 16-bits from 0 to 15. You can still index a bit position outside the bounds of this array with something like myArray.0[16]=1. This will not generate an error at compile time, and it will set a bit outside the bounds of your array. So you need to be careful. You can affect areas outside the bounds of an array.
    Last edited by Bruce; - 19th October 2005 at 16:22.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Reading in Manchester code
    By brid0030 in forum Code Examples
    Replies: 0
    Last Post: - 10th March 2009, 21:55
  2. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  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