I was trying to use the SPI shiftout bit-banging routines on page 229 of the PICAXE manual and having no success.
I searched the forum and found this old thread from 2007 in the archive: Shiftout Error in samples directory code
When I compared the code to the shiftin_out.bas code (in the samples folder) to the code in the manual, there is indeed a difference.
I changed my code to match that in the shiftin_out.bas and the routine works great now!
I assume that the manual is in error.
Code from manual
if mask = 0 then skipMSB
Code from shiftin_out.bas
if mask = MSBValue then skipMSB
I searched the forum and found this old thread from 2007 in the archive: Shiftout Error in samples directory code
When I compared the code to the shiftin_out.bas code (in the samples folder) to the code in the manual, there is indeed a difference.
I changed my code to match that in the shiftin_out.bas and the routine works great now!
I assume that the manual is in error.
Code from manual
if mask = 0 then skipMSB
Code:
shiftout_MSBFirst:
for counter = 1 to bits ‘ number of bits
mask = var_out & MSBValue ‘ mask MSB
high sdata ‘ data high
if mask = 0 then skipMSB
low sdata ‘ data low
skipMSB:
pulsout sclk,1 ‘ pulse clock for 10us
var_out = var_out * 2 ‘ shift variable left for MSB
next counter
return
if mask = MSBValue then skipMSB
Code:
shiftout_MSBFirst:
for counter = 1 to bits ' number of bits
mask = var_out & MSBValue ' mask MSB
high sdata ' data high
if mask = MSBValue then skipMSB
low sdata ' data low
skipMSB:
pulsout sclk,1 ' pulse clock for 10us
var_out = var_out * 2 ' shift variable left for MSB
next counter
return