Shiftout Question.
Clock Loop
Posts: 2,069
Why doesn't this work
What Im trying to do here is take the number in variable Xady, convert it to at LEAST & MOST 7 bits binary, and then shift it out. I dont want
it to be converted to 8 bits binary due to me sending the 8th bit already.
This only works with multiples of 2. Is this a BS2 (or pbasic) code limitation?
SHIFTOUT Dpin, Clk, MSBFIRST, [noparse][[/noparse]0, Xady\7]
What Im trying to do here is take the number in variable Xady, convert it to at LEAST & MOST 7 bits binary, and then shift it out. I dont want
it to be converted to 8 bits binary due to me sending the 8th bit already.
This only works with multiples of 2. Is this a BS2 (or pbasic) code limitation?
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
I meant this
SHIFTOUT Dpin, Clk, MSBFIRST, [noparse][[/noparse]%0, Xady\7]
But if you just told me I could do a \1, does that mean I can do a \7?
Anyone know of a better way to reduce FOR loops AND not use so many "%0\16"
Basically with this code below, I am trying to CLOCK out 448 bits of binary bit "0".
I am trying to use as little for loops as possible, to make the code run faster.
Is my only option to do this WITH out using loop code to manually put in 28 copys of "%0\16" ?
FOR cursor = 1 TO 9 SHIFTOUT Dpin, Clk, MSBFIRST, [noparse][[/noparse]%0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16, %0\16] NEXT
· LOW Dpin
· LOW Cpin
· FOR idx = 0 TO 447
··· PULSOUT Cpin,·10
· NEXT
This creates 448 clock pulses with the data line low (0). You may need to adjust the width of the clock pulse for your device.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
LOW Dpin LOW Cpin PWM Cpin,64,7
On the other thing, you need
SHIFTOUT Dpin, Clk, MSBFIRST, [noparse][[/noparse]%0\1, Xady\7]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
That is neat, compact, esoteric, insightful and downright CAGEY!
As always, my hat's off to a possibly perfect solution, and its author!
Regards,
Bruce Bates
Can't wait to try all of your suggestions.....
I am still working on the revision of my old circuit,, adding alot more... this is for the nokia cell phone LCD project. (in projects forum)
I am sure I will have alot more quesitons once I finally wire up my keypad to my 74hc597 & 74hc595.
I am basically running the keypad, and lcd display, and power button from 4 lines. Data, Clock, Latch, and Reset.
The complete program and schematic will be updated in the "Nokia LCD" thread under Projects Forum.
It will be a few days tho because Ive never attempted a circuit with both shiftin and shiftout devices, operating from the same clock and data lines.
LOW Dpin LOW Cpin PWM Cpin,64,7 LOW Cpin ' or have a pulldown R on Cpin to force it low after the PWM
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com