SolidWorksMagi
Senior Member
Hi,
I want to send specific data patterns to a 74HC595 chip to turn on specific LEDs and eventually, hold on that pattern ... but this do loop doesn't seem to get me any results ??? Can anybody tell me what's wrong with my little do loop?
setfreq m4 ; All M2 parts internal k31, k250, k500, m1, m2, m4, m8, m16, m32
symbol SER = C.0 ; SER (pin 14) is for data bit to SR.
symbol SDCK = C.1 ; SDCK (pin 11) data clock
symbol SDCLR = C.2 ; SDCLR (pin 10) clear data register on LOW.
symbol LATCH = C.6 ; LATCH (pin 12 RCK) HIGH latches SR data
symbol ENABLE= C.7 ; ENABLE output for latch data (pin 13 or G-NOT)
do
for j = 0 to 84 ;= 01010101
val = j
for i = 1 to 8
temp1 = val & %01010101
if temp1 = 1 then HIGH SER
else LOW SER
endif
pulsout SDCK,1
val = val / 2 ; shift bits one place right
next i
pulsout LATCH,1
; data retained until next cycle
next j
loop
This do loop does work but is not what I want;
do
for j = 0 to 255
val = j
for i = 1 to 8
temp1 = val & %00000001
if temp1 = 1 then HIGH SER
else LOW SER
endif
pulsout SDCK,1
val = val / 2 ; shift bits one place right
next i
pulsout LATCH,1
; data retained until next cycle
pause 500 ; Determines time between each count/display
next j
loop
I want to send specific data patterns to a 74HC595 chip to turn on specific LEDs and eventually, hold on that pattern ... but this do loop doesn't seem to get me any results ??? Can anybody tell me what's wrong with my little do loop?
setfreq m4 ; All M2 parts internal k31, k250, k500, m1, m2, m4, m8, m16, m32
symbol SER = C.0 ; SER (pin 14) is for data bit to SR.
symbol SDCK = C.1 ; SDCK (pin 11) data clock
symbol SDCLR = C.2 ; SDCLR (pin 10) clear data register on LOW.
symbol LATCH = C.6 ; LATCH (pin 12 RCK) HIGH latches SR data
symbol ENABLE= C.7 ; ENABLE output for latch data (pin 13 or G-NOT)
do
for j = 0 to 84 ;= 01010101
val = j
for i = 1 to 8
temp1 = val & %01010101
if temp1 = 1 then HIGH SER
else LOW SER
endif
pulsout SDCK,1
val = val / 2 ; shift bits one place right
next i
pulsout LATCH,1
; data retained until next cycle
next j
loop
This do loop does work but is not what I want;
do
for j = 0 to 255
val = j
for i = 1 to 8
temp1 = val & %00000001
if temp1 = 1 then HIGH SER
else LOW SER
endif
pulsout SDCK,1
val = val / 2 ; shift bits one place right
next i
pulsout LATCH,1
; data retained until next cycle
pause 500 ; Determines time between each count/display
next j
loop
Last edited: