Discussion forum for the BasicX family of microcontroller chips.
|
I have a question on ShiftOut. Does the shift out function remove the bits from the variable that the bits are being shifted out? I have a 5 bit variable. I want to shift out one bit at a time when one of the signals goes HIGH. Would it work if I put it in a do- while loop? What I'm afraid is that it would shift out least significant bit over and over again. Thanks in advance. |
|
|
|
Not quite sure of your question. Shiftout shifts the MSB first. If the ck is high before shifout is called, clock pulse will be low going for the shiftout proceedure. and vise versa. Shiftout leaves the data pin high. The operasnd remains intact. In your case you would: call shiftout(datapin,ckpin,5,operand) neil tiger_gk wrote: > I have a question on ShiftOut. Does the shift out function remove > the bits from the variable that the bits are being shifted out? I > have a 5 bit variable. I want to shift out one bit at a time when > one of the signals goes HIGH. Would it work if I put it in a do- > while loop? What I'm afraid is that it would shift out least > significant bit over and over again. Thanks in advance. > Yahoo! Groups Sponsor > ADVERTISEMENT > <http://rd.yahoo.com/M=267637.4116719.5338353.1261774/D=egroupweb/S=1706554205:HM/A=1754451/R=0/SIG=11tpj98m3/*http://www.netflix.com/Default?mqso=60178323&partid=4116719 > > >. [Non-text portions of this message have been removed] |
|
|
|
Thanks for your reply. I think I wasn't being very clear on my question. There are two cases that I have questions on. Case 1: So say I have 5 bits. I want to shift out bits while pin 6 is HIGH and when pin 6 goes LOW I want to stop shifting out. So It shifts out bits while pin 6 is high. So if the period pin 6 stays high is long enough it will shift out all 5 bits but if it's not that long it will only be able to shift out one bit. However I still want to shift out the bits in order. So if the HIGH period is short and I only get to shift out the MSB, on the next HIGH period I want to shift out 2nd to MS bit. Case 2: I have 5 bits. I want to shift out one bit at a time when pin 5 goes LOW. Pin 5 goes LOW and comes back to HIGH. I want to shift out 1 bit on the negative edges. bit 4 then bit 3 then bit 2 , bit 1, bit 0... all in order but one bit per edge. For both cases, if the 5 bits in the variable A is 10110. I want it to output 1 ->0 -> 1 -> 1 -> 0 and stop. Does Shift Out somewhat work like Shift Left in assembly? Does 10110 becomes 01101 after performing ShiftOut(data, clk, 1, A) ?? Thanks in advance. -Glenn --- In , Neil Jepsen <njepsen@i...> wrote: > Not quite sure of your question. Shiftout shifts the MSB first. If the > ck is high before shifout is called, clock pulse will be low going for > the shiftout proceedure. and vise versa. Shiftout leaves the data pin > high. The operasnd remains intact. > In your case you would: > call shiftout(datapin,ckpin,5,operand) > neil > tiger_gk wrote: > > > I have a question on ShiftOut. Does the shift out function remove > > the bits from the variable that the bits are being shifted out? I > > have a 5 bit variable. I want to shift out one bit at a time when > > one of the signals goes HIGH. Would it work if I put it in a do- > > while loop? What I'm afraid is that it would shift out least > > significant bit over and over again. Thanks in advance. > > > > > > Yahoo! Groups Sponsor > > ADVERTISEMENT > > <http://rd.yahoo.com/M=267637.4116719.5338353.1261774/D=egroupweb/S=17 06554205:HM/A=1754451/R=0/SIG=11tpj98m3/*http://www.netflix.com/Default? mqso=60178323&partid=4116719> > > > > > > > > >. > > [Non-text portions of this message have been removed] |
|
|
|
To my knowledge, ShiftOut always completes shifting out the number of bits that you specify. To accomplish what you've described, you'll have to perform the shifting and output yourself while monitoring the controlling pin. Alternately, you may find it simpler to add some external hardware to implement the gated shifting. Don in Portland, OR --- In , "tiger_gk" <tiger_gk@y...> wrote: > Thanks for your reply. I think I wasn't being very clear on my question. There > are two cases that I have questions on. > > Case 1: So say I have 5 bits. I want to shift out bits while pin 6 is HIGH and > when pin 6 goes LOW I want to stop shifting out. So It shifts out bits while pin > 6 is high. So if the period pin 6 stays high is long enough it will shift out all 5 > bits but if it's not that long it will only be able to shift out one bit. However I still > want to shift out the bits in order. So if the HIGH period is short and I only get > to shift out the MSB, on the next HIGH period I want to shift out 2nd to MS bit. > > Case 2: I have 5 bits. I want to shift out one bit at a time when pin 5 goes > LOW. Pin 5 goes LOW and comes back to HIGH. I want to shift out 1 bit on the > negative edges. bit 4 then bit 3 then bit 2 , bit 1, bit 0... all in order but one bit > per edge. > > For both cases, if the 5 bits in the variable A is 10110. I want it to output 1 > ->0 -> 1 -> 1 -> 0 and stop. > > Does Shift Out somewhat work like Shift Left in assembly? > Does 10110 becomes 01101 after performing ShiftOut(data, clk, 1, A) ?? > Thanks in advance. > -Glenn > --- In , Neil Jepsen <njepsen@i...> wrote: > > Not quite sure of your question. Shiftout shifts the MSB first. If the > > ck is high before shifout is called, clock pulse will be low going for > > the shiftout proceedure. and vise versa. Shiftout leaves the data pin > > high. The operasnd remains intact. > > In your case you would: > > call shiftout(datapin,ckpin,5,operand) > > neil > > > > > > tiger_gk wrote: > > > > > I have a question on ShiftOut. Does the shift out function remove > > > the bits from the variable that the bits are being shifted out? I > > > have a 5 bit variable. I want to shift out one bit at a time when > > > one of the signals goes HIGH. Would it work if I put it in a do- > > > while loop? What I'm afraid is that it would shift out least > > > significant bit over and over again. Thanks in advance. > > > > > > > > > Yahoo! Groups Sponsor > > > ADVERTISEMENT > > > > <http://rd.yahoo.com/M=267637.4116719.5338353.1261774/D=egroupweb/S=17 > 06554205:HM/A=1754451/R=0/SIG=11tpj98m3/*http://www.netflix.com/Defaul t? > mqso=60178323&partid=4116719> > > > > > > > > > > > > >. > > > > > > > > [Non-text portions of this message have been removed] |
|
Hi Glenn I havn't tried it, but my impression is if you called ShiftOut(data, clk, 1, A)on a 5 bit variable, only the msb would get shifted out and the variable remains unchanged. If you did ShiftOut(data, clk, 1, A) a second time, the same msb would get shifted out, so you would need to do a manipulation to move the bits one to the left before you did this. (perhaps a x2 then AND 011111 to shift the MSB out) Why do you want to do this? Why not shift out all 5 bits and do the manipulation on he bits at the other end? Does Shift Out somewhat work like Shift Left in assembly? Does 10110 becomes 01101 after performing ShiftOut(data, clk, 1, A) ?? NO the source variable remains unchanged. tiger_gk wrote: > Thanks for your reply. I think I wasn't being very clear on my > question. There > are two cases that I have questions on. > > Case 1: So say I have 5 bits. I want to shift out bits while pin 6 is > HIGH and > when pin 6 goes LOW I want to stop shifting out. So It shifts out bits > while pin > 6 is high. So if the period pin 6 stays high is long enough it will > shift out all 5 > bits but if it's not that long it will only be able to shift out one > bit. However I still > want to shift out the bits in order. So if the HIGH period is short > and I only get > to shift out the MSB, on the next HIGH period I want to shift out 2nd > to MS bit. > > Case 2: I have 5 bits. I want to shift out one bit at a time when pin > 5 goes > LOW. Pin 5 goes LOW and comes back to HIGH. I want to shift out 1 bit > on the > negative edges. bit 4 then bit 3 then bit 2 , bit 1, bit 0... all in > order but one bit > per edge. > > For both cases, if the 5 bits in the variable A is 10110. I want it to > output 1 > ->0 -> 1 -> 1 -> 0 and stop. > > Does Shift Out somewhat work like Shift Left in assembly? > Does 10110 becomes 01101 after performing ShiftOut(data, clk, 1, A) ?? > Thanks in advance. > -Glenn > --- In , Neil Jepsen <njepsen@i...> wrote: > > Not quite sure of your question. Shiftout shifts the MSB first. If > the > > ck is high before shifout is called, clock pulse will be low going for > > the shiftout proceedure. and vise versa. Shiftout leaves the data pin > > high. The operasnd remains intact. > > In your case you would: > > call shiftout(datapin,ckpin,5,operand) > > neil > > > > > > tiger_gk wrote: > > > > > I have a question on ShiftOut. Does the shift out function remove > > > the bits from the variable that the bits are being shifted out? I > > > have a 5 bit variable. I want to shift out one bit at a time when > > > one of the signals goes HIGH. Would it work if I put it in a do- > > > while loop? What I'm afraid is that it would shift out least > > > significant bit over and over again. Thanks in advance. > > > > > > > > > Yahoo! Groups Sponsor > > > ADVERTISEMENT > > > > <http://rd.yahoo.com/M=267637.4116719.5338353.1261774/D=egroupweb/S=17 > 06554205:HM/A=1754451/R=0/SIG=11tpj98m3/*http://www.netflix.com/Default? > mqso=60178323&partid=4116719> > > > > > > > > > > > > >. > > > > > > > > [Non-text portions of this message have been removed] > Yahoo! Groups Sponsor > <http://rd.yahoo.com/M=259395.3614674.4902533.1261774/D=egroupweb/S=1706554205:HM/A=1524963/R=0/SIG=12o885gmo/*http://hits.411web.com/cgi-bin/autoredir?camp=556&lineid=3614674&prop=egroupweb&pos=HM > > >. [Non-text portions of this message have been removed] |