Quantcast
Channel: MEL PICBASIC Forum
Viewing all articles
Browse latest Browse all 4787

A (possibly) odd way to access a port

$
0
0
I'm using the lower 6 bits of PORTC (16F886) as select lines for other chips. These bits would be set as outputs.

Can I use the following to access individual bits of PORTC? (I suspect not - but I've searched the manual and the forum and can't seem to find the answer)

Code:

COUNTER VAR BYTE

FOR COUNTER = 0 TO 5
        PORTC.COUNTER = 0 'SET THE PORTC PIN LOW
NEXT COUNTER

My other idea was to use an array.

Code:

EN_ARRAY VAR BYTE[6]
COUNTER VAR BYTE

EN_ARRAY[0] VAR PORTC.0
EN_ARRAY[1] VAR PORTC.1
EN_ARRAY[2] VAR PORTC.2
EN_ARRAY[3] VAR PORTC.3
EN_ARRAY[4] VAR PORTC.4
EN_ARRAY[5] VAR PORTC.5

FOR COUNTER = 0 TO 5
      EN_ARRAY[COUNTER] = 0  'SET PORTC PIN TO 0
NEXT COUNTER

If neither of these would work, any other ideas - it would simplify this project a lot if I can use an index of some sort to access those pins.

Thanks,

Andy

Viewing all articles
Browse latest Browse all 4787

Trending Articles