pin / outpin clarification

mjy58

Member
Having struggled with the concepts of pin and outpin, I hope someone can assist.

The following code simulates and runs correctly on chip
Code:
#picaxe 18m2
#no_data
dirsb = %11111111	;Set port b as output
dirsc = %00000000	;Set port c as input
symbol dataout	= b0 ;w0 and bit 0 to bit 7
symbol pad		= b1 ;w0 and bit 8 to bit 15
symbol clock	= b.1
symbol strobe	= b.2
main:
dataout 	= %01000000 'data to send
pad		= %11111111
low strobe ; Strobe low at start of data
high clock	; Ensure clock is high for pulseout
do
  pinb.0 = bit0 ;Make b.0 the value in bit0
  w0 = w0/2
  pulsout clock,100 ' 100ms clock pulse
loop Until b1 = 0
high strobe ; Strobe high at end of data
goto main
However according to these threads (and others)
http://www.picaxeforum.co.uk/showthread.php?9831-Data-Shift-Out
http://www.picaxeforum.co.uk/showthread.php?20369-AXE049-Code-Questions

I interpret the 'preferred' method of referencing an output pin is with the 'outpin' command rather than the 'pin' command.

Manual 2 V7.8 also confirms for an 18M2 the outpinb.0 is a valid command.

However the following version of the code gives a syntax error:

outpinb.0 = bit0 ;Make b.0 the value in bit0
^

Error: Unknown symbol - outpinb.0
Code:
#picaxe 18m2
#no_data
dirsb = %11111111	;Set port b as output
dirsc = %00000000	;Set port c as input
symbol dataout	= b0 ;w0 and bit 0 to bit 7
symbol pad		= b1 ;w0 and bit 8 to bit 15
symbol clock	= b.1
symbol strobe	= b.2
main:
dataout 	= %01000000 'data to send
pad		= %11111111
low strobe ; Strobe low at start of data
high clock	; Ensure clock is high for pulseout
do
  outpinb.0 = bit0 ;Make b.0 the value in bit0
  w0 = w0/2
  pulsout clock,100 ' 100ms clock pulse
loop Until b1 = 0
high strobe ; Strobe high at end of data
goto main
Any advice appreciated.

Malcolm
 

westaust55

Moderator
I concur that according to PICAXE manual 2 (currently V7/8) page 15 the term "outpinB.x" should function correctly.

Using the PE (5.5.0) if used with an X2 part selected. the code does pass the syntax test
but for an M2 part such as the 14M2, 18M2 or 20M2 the outpinB.x brings up a syntax error however it passes for the 08M2.


The same situation applied within the PE for outpinC.x

Certainly the assignment:
pinB.x = constant/variable
will also work, so for now I suggest that you use that format.
 
Top