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.
Bookmarks