I can see what you are trying to do. Basically, you have an integer that you want to put on 2 x 8 bit shift registers. The integer will change based on the pattern you want displayed. This is straightforward like you're doing it now. But, if you wish to light each LED one by one depending on the input word, this will do it
Code:
outputword var word ' this goes to the shift registers
bitpos var word ' roll the bit you wish to mask out
Main:
serin portc.7,6,lowbyte 'sit and wait for an input
serin portc.7,6,highbyte 'sit and wait for an input
outdata.lowbyte = lowbyte
outdata.highbyte = highbyte
if outdata = 0 then ' pause time according to turning on or off
Tptime = 0
else
Tptime = ptime 'from eprom
endif
bitpos = 1
FOR LoopCount = 1 to 16 ' for each bit of the input
OutputWord = bitmask & bitpos
gosub SyncSend
bitpos = bitpos << 1 ' move the bit 1 place to the left
' so that we can read the next bit
pause TPtime ' wait for the pause time you want
next
GOTO Main
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
;----[Send synchronous data]------------------------------------------------
SyncSend:
SHIFTOUT SDout, SClk, 1,[OutputWord\16]
HIGH Strobe ; strobe the shift registers latches
@ NOP ; hold Strobe for 1uS
LOW Strobe ; Strobe idles LOW
RETURN
this line will let you light 1 led at a time (dot mode)
bitpos = bitpos << 1 ' move the bit 1 place to the left so that we can read the next bit
But this will let you retain the ones that are already lit (bar mode)
bitpos = bitpos << 1 +1 ' move the bit 1 place to the left so that we can read the next bit and retain the one that was on previously
Bookmarks