Compiler bug?

Is it a bug or is it me? (Probably the latter)

The first readadc statement does not work (nothing placed in b0) wheras the second statement works.

#PICAXE 20X2
symbol LDC = B.4
adcsetup = %0000000001000000
readadc LDC,b0 ; This statement does not work
readadc B.4,b0 ; This works
 

KeithRB

Senior Member
Maybe you should correct the ReadADC example in Manual 2, since it uses the pin number, or at least point out that the example does not apply to X2 parts.
 

hippy

Ex-Staff (retired)
@ KeithRB : The "readadc C.1,b1" example in the manual is correct for all parts using port.pin notation.

When the port.pin is used inline in the command as here the compiler automagically sorts out which actual ADC channel to use. It's only when a symbol is used to specify the channel number of the READADC does the issue arise.

For example, for the 20X2 the ADC channel for pin C.2 ( leg 8 ) is ADC8, so these two are the same ...

ReadAdc 8, b0

Symbol POT_ADC = 8
ReadAdc POT_ADC, b0

The compiler also converts "ReadAdc C.2" to "ReadAdc 8" but this will not happen for the following case -

Symbol POT_ADC = C.2
ReadAdc POT_ADC, b0

The "C.2" has a pin numbering value of "10" so this ends up as "ReadAdc 10" not the "ReadAdc 8" desired.
 

KeithRB

Senior Member
I understand completely, but the example completely glosses over that the *channel* is required, not strictly the port.pin.

For example, the ReadADC10 command contains this caveat:
"On X2 parts you must use the ADC channel, not the pin number, in the readadc
command (e.g. readadc10 0,w1 NOT readadc10 A.0, w1)"
 
Top