Cannot use 20X2 "A.0" pin as output ????

OLDmarty

Senior Member
Hi All,

I can't seem to assign pin A.0 to my code, it gives me a syntax error. (sorry, i'm not near the PC to cut''n'paste a screenshot of the error).

For example, I'm assigning "pinA.0 = bit0" in my code.
Am i perhaps using the wrong "pin" syntax for the 20X2?

However, all other pins B.0 to B.7 and C.0 to C.7 (except c.6 which is fixed input) can be assigned to my 'bits' and the code works.
It just seems to be something unique about A.0 that prevents me using it at the moment.

All i am doing is assigning all pins on B & C port as well as A.0 to the 16 bits of a word variable. (this works perfectly on my 28X2 and 40X2 correctly).

This code example works on my 28X2 and 40X2 perfectly.... in fact this also works on the 20X2 when using only the B & C ports....but trying to assign A.0 is when i get the error.

(YES, i have configured the appropriate ports as outputs and set them all to "0" at the beginning of code etc etc).

Code:
#picaxe 28X2
#no_table
#no_data

setfreq m8

symbol Zport = w0

dirsB = %11111111		'set PortB to all OUTPUTS
dirsC = %11111111		'set PortC to all OUTPUTS

outpinsB = $00		'clear PortB otputs to all 0's
outpinsC = $00		'clear PortC otputs to all 0's



do

for Zport = $0000 to $FFFF	'create a 16bit binary counter

pinC.0 = bit0			'joining together PortB + PortC, now known as "Zport"
pinC.1 = bit1			'these could be ANY bits you prefer, using bits from Port A,B,C & D etc...
pinC.2 = bit2 
pinC.3 = bit3 
pinC.4 = bit4 
pinC.5 = bit5 
pinC.6 = bit6 
pinC.7 = bit7 
pinB.0 = bit8 
pinB.1 = bit9 
pinB.2 = bit10 
pinB.3 = bit11 
pinB.4 = bit12 
pinB.5 = bit13 
pinB.6 = bit14 
pinB.7 = bit15 

next Zport 

loop

I know pin A.0 is fixed output and also used for SEROUT programming use.

So, is there something i need to do to access A.0 to use as an output?
I thought it might be "disconnect" but that seems to be for SERIN pins.

Anyone?

;-)
 

AllyCat

Senior Member
Hi,

"Port A" is not an "official" port on 20-pin PICaxes (M2 or X2) and I don't think you'll find it described in any formal documentation. There is just a very rudimentary "patch" to allow Leg 19 to be referred to explicitly as pin "A.0". But AFAIR, "A.0" cannot be used even in Symbol commands and there is no equivalent at all for the Serial (Programming) Input (Leg 2).

Cheers, Alan.
 

inglewoodpete

Senior Member
"Port A" is not an "official" port on 20-pin PICaxes (M2 or X2) and I don't think you'll find it described in any formal documentation. There is just a very rudimentary "patch" to allow Leg 19 to be referred to explicitly as pin "A.0". But AFAIR, "A.0" cannot be used even in Symbol commands and there is no equivalent at all for the Serial (Programming) Input (Leg 2).
I just ran the following code through the syntax checker and it does not report any errors.

Code:
   Symbol oTestPin = OutPinA.0

          oTestPin = bit0
I have to admit that I have never used A.0 on a 20X2, though.
 

OLDmarty

Senior Member
Thanks guys, i forgot about that dreaded "outpin" command (which i never use in my 28x2 and 40x2 coding) lol ;-)

I adjusted my line of (A.0) code to become "OutPinA.0" and also see it compiles/syntax checks with no errors.
(i won't know the true outcome until i'm plugged back into my test jig at work).

Does it now make sense that i should always keep using "outpin" for all my coding in future?
I mostly (95%) use 28X2 and 40X2 chips, with the rare occasion to downsize to the odd 20X2 or 'M2' chips.

Thanks in advance...
 

hippy

Senior Member
Does it now make sense that i should always keep using "outpin" for all my coding in future?
That would be recommended when dealing with pins which are used as outputs.

I too have a habit of using "pinX.Y=" when setting outputs which I find hard to break away from. The compiler converts those to "outpinX.Y=" but can only do that in cases where the pin can be an input and "pinX.Y" makes sense and has been defined for the compiler.

If "pinA.0" existed for the 20X2 the compiler would accept "b0 = pinA.0" and similar which doesn't make sense, so, to prevent that, "pinA.0" is not defined for the compiler, even though "outpinA.0" is.

You can fake a "pinA.0" using "Symbol pinA.0 = outpinA.0" but that then can get confusing with things like "b0=pinA.0" which appears to be reading an input but is actually reading how the output pin has been set.

So the full recommendation is to use "outpinX.Y=" for setting outputs, use "=pinX.Y" for inputs, and "=outpinX.Y" if reading how an output pin has been set.
 

OLDmarty

Senior Member
That would be recommended when dealing with pins which are used as outputs.

I too have a habit of using "pinX.Y=" when setting outputs which I find hard to break away from. The compiler converts those to "outpinX.Y=" but can only do that in cases where the pin can be an input and "pinX.Y" makes sense and has been defined for the compiler.

If "pinA.0" existed for the 20X2 the compiler would accept "b0 = pinA.0" and similar which doesn't make sense, so, to prevent that, "pinA.0" is not defined for the compiler, even though "outpinA.0" is.

You can fake a "pinA.0" using "Symbol pinA.0 = outpinA.0" but that then can get confusing with things like "b0=pinA.0" which appears to be reading an input but is actually reading how the output pin has been set.

So the full recommendation is to use "outpinX.Y=" for setting outputs, use "=pinX.Y" for inputs, and "=outpinX.Y" if reading how an output pin has been set.

Thanks Hippy, greatly appreciate the clarification...
 
Top