PDA

View Full Version : Pin outputs to an array



Firegod
- 20th March 2007, 16:57
I would like to associate 32 pins of my 18F4525 to an array such as ch_out[32]. I am having trouble getting anything to compile.

This will not work:
ch_out VAR BIT[32]
ch_out[1] VAR PORTA.1

This will not work:
ch_out VAR BIT[32]
SYMBOL ch_out[1] = PORTA.1

This will not work:
SYMBOL ch_out[1] = PORTA.1

This will not work:
ch1 VAR PORTA.1
SYMBOL ch_out[1] = ch1

This will not work:
ch1 VAR PORTA.1
ch_out[1] VAR ch1

I want to process all the pins in one loop by incrementing a loop counter and turning the pin on or off using an IF THEN statement. For example:

FOR cnt = 1 to 32
IF ch_data[cnt] >= 1 THEN
HIGH ch_out[cnt]
ELSE
LOW ch_out[cnt]
ENDIF
NEXT cnt

Anyone have a solution?

Darrel Taylor
- 20th March 2007, 17:35
See this ...

Indexing Port Pins
http://www.picbasic.co.uk/forum/showthread.php?t=3753
<br>