loop index problem
I'm trying to build a little handshaking protocol and am running into a problem with my loop.
The programming is a little different than the way I would program in C.
I get the error: "EXPECTED A VALUE BETWEEN 0 AND 7 "idx"
should i just make an array?
is there a convenient way to copy a byte into an array then?
any suggestions would really be appreciated.
The programming is a little different than the way I would program in C.
tmp1 VAR BYTE
...
...
...
FUNC SHIFTOUT_VAL
'tmp0 = __PARAMCNT
tmp1 = __PARAM1
'tmp2 = __PARAM2
'tmp3 = __PARAM3
'tmp4 = __PARAM4
FOR idx = 7 TO 0 STEP -1
IF SCLK = 1 THEN
IF tmp1.idx <> 0 THEN
HIGH MISO
ELSE
LOW MISO
ENDIF
ELSE
pause 1
ENDIF
NEXT
ENDFUNC
I get the error: "EXPECTED A VALUE BETWEEN 0 AND 7 "idx"
should i just make an array?
is there a convenient way to copy a byte into an array then?
any suggestions would really be appreciated.

Comments
SUB SHIFTOUT_VAL soVal VAR tmpB1 ' value to shift out, LSB first soIdx VAR tmpB2 ' loop control soVal = __param1 FOR soIdx = 0 TO 7 ' send 8 bits \ JB SCLK, @$ ' wait for low \ JNB SCLK, @$ ' wait for leading edge \ nop ' let SCLK settle MiSo = soVal.0 ' output LSB soVal = soVal >> 1 ' prep for next bit NEXT ENDSUBNote that if you're trying to synchronize with an external clock (coming in on SCLK) you cannot insert arbitrary delays as you have. The above code waits for a rising edge of the SCLK line before outputting the LSB of the value to sent over in __param1.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hodge
webbolts.com
forumexperts.com