I am trying to use the 14M2 with SPI. I read that I have to substitute some code. Question. Is the standard HSpiout MSB of LSB first? I would like to know if there are any compiler directives available so that I can retain the same name and format as the X2 ie. HspiOut ( xx ). ie. - How does the compiler handle / put this value? ( xx )
If not, then does this mean I have to use both a different name and layout? ie. at the bottom here I have made an attempt. Am I even close?
Sorry to post yet another question. But I have a deadline in three days. A simple enough project but I didnt quite expect the uphill battle of grasping some details. But apart from my initial startup problems, this is a fantastic concept, and I can see myself sticking with it.
;---------------------------------------------------------
For X2 series
HSpiOut ( $7F )
;---------------------------------------------------------
For M2 series - substitute
‘***** Sample symbol definitions *****
symbol sclk = 5 ; clock (output pin)
symbol sdata = 7 ; data (output pin for shiftout)
symbol serdata = input7 ; data (input pin for shiftin, note input7)
symbol counter = b7 ; variable used during loop
symbol mask = w4 ; bit masking variable
symbol var_in = w5 ; data variable used durig shiftin
symbol var_out = w6 ; data variable used during shiftout
symbol bits = 8 ; number of bits
symbol MSBvalue = 128 ; MSBvalue =128 for 8 bits, 512 for 10 bits, 2048 for 12 bits)
My best guess.
MyHSpiOut:
var_out = $7F : gosub shiftout_MSBFirst
return
If not, then does this mean I have to use both a different name and layout? ie. at the bottom here I have made an attempt. Am I even close?
Sorry to post yet another question. But I have a deadline in three days. A simple enough project but I didnt quite expect the uphill battle of grasping some details. But apart from my initial startup problems, this is a fantastic concept, and I can see myself sticking with it.
;---------------------------------------------------------
For X2 series
HSpiOut ( $7F )
;---------------------------------------------------------
For M2 series - substitute
‘***** Sample symbol definitions *****
symbol sclk = 5 ; clock (output pin)
symbol sdata = 7 ; data (output pin for shiftout)
symbol serdata = input7 ; data (input pin for shiftin, note input7)
symbol counter = b7 ; variable used during loop
symbol mask = w4 ; bit masking variable
symbol var_in = w5 ; data variable used durig shiftin
symbol var_out = w6 ; data variable used during shiftout
symbol bits = 8 ; number of bits
symbol MSBvalue = 128 ; MSBvalue =128 for 8 bits, 512 for 10 bits, 2048 for 12 bits)
;----------------------------------------------------------‘ ***** Shiftout MSB first *****
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
My best guess.
MyHSpiOut:
var_out = $7F : gosub shiftout_MSBFirst
return
Last edited: