Discussion forum for the BasicX family of microcontroller chips.
|
Hello All, I have some questions regarding the ShiftIn and ShiftOut system calls. I failed to find these details in the BX documentation In what order are the bits sent with the ShiftOut procedure? Similar: what position do incoming bits occupy into the byte returned by the ShiftIn function? Also, are any remaining bits of the byte padded with zeros or left to their earlier values? What is the duration of the clock hi and lo pulse? I understand its cycle is in the 1-2us order, to be compatible with 400 kHz systems - but how long is it exactly? Can it be adjusted? Thanks in advance. Geroge Chamilothoris |
|
|
|
--- George Chamilothoris <> wrote: > Hello All, > I have some questions regarding the ShiftIn and ShiftOut system > calls. I > failed to find these details in the BX documentation > In what order are the bits sent with the ShiftOut procedure? Normaly the MSB is sent first. > Similar: > what > position do incoming bits occupy into the byte returned by the > ShiftIn > function? the frist bit that is sent will be located in the LSB position. then that bit is shifted left the next bit will go into the LSB position and the sysle starts over again. Also, are any remaining bits of the byte padded with zeros > or left > to their earlier values? all bits start as 0. if you are shifting the value of 127 into a byte then you will have 01111111 if you are shifting that into an integer you will have 0000000001111111 > What is the duration of the clock hi and lo pulse? I understand its > cycle is > in the 1-2us order, to be compatible with 400 kHz systems - but how > long is > it exactly? Can it be adjusted? as far as I know there are two ways you can adjust the speed (not the duration of the pulse) and only one way to adjust the pulse length. #1 to slow the speed down shift out one bit at a time with a dealy or sleep between them. #2 to make the pulse longer And to slow the speed down you will have to make your own sub. setup: clock line low data line unknown (shift out the value of 5) = 00000101 call putpin(dataline,bxoutputlow)'0 call putpin(clockline,bxoutputhigh) call sleep(1) ' or what ever you need call putpin(clockline,bxoutputlow) call putpin(dataline,bxoutputlow)'0 call putpin(clockline,bxoutputhigh) call sleep(1) ' or what ever you need call putpin(clockline,bxoutputlow) call putpin(dataline,bxoutputlow)'0 call putpin(clockline,bxoutputhigh) call sleep(1) ' or what ever you need call putpin(clockline,bxoutputlow) call putpin(dataline,bxoutputlow)'0 call putpin(clockline,bxoutputhigh) call sleep(1) ' or what ever you need call putpin(clockline,bxoutputlow) call putpin(dataline,bxoutputlow)'0 call putpin(clockline,bxoutputhigh) call sleep(1) ' or what ever you need call putpin(clockline,bxoutputlow) call putpin(dataline,bxoutputhigh)'1 call putpin(clockline,bxoutputhigh) call sleep(1) ' or what ever you need call putpin(clockline,bxoutputlow) call putpin(dataline,bxoutputhigh)'0 call putpin(clockline,bxoutputhigh) call sleep(1) ' or what ever you need call putpin(clockline,bxoutputlow) call putpin(dataline,bxoutputlow)'1 call putpin(clockline,bxoutputhigh) call sleep(1) ' or what ever you need call putpin(clockline,bxoutputlow) all done. it would be easyer to make a sub to do this public sub ShiftOutSlow(byval value as byte, byval NumBits as byte, byval SleepVal as integer) dim loopcounter as byte for loopcounter = Numbits to 0 step -1 if (getbit(value,loopcounter)=1) then call putpin(dataline,bxoutputhigh)'1 call putpin(clockline,bxoutputhigh) call sleep(sleepval) call putpin(clockline,bxoutputlow) else call putpin(dataline,bxoutputlow)'0 call putpin(clockline,bxoutputhigh) call sleep(sleepval) call putpin(clockline,bxoutputlow) endif end sub > Thanks in advance. > Geroge Chamilothoris > ===== Tony Brenke North Tacoma, WA __________________________________________________ |
|
George, Are you planning to use the shift command for communication with the Stamp II? Alexander Arnote >From: "George Chamilothoris" <> >Reply-To: >To: <> >Subject: Re: [BasicX] Digest Number 518 >Date: Wed, 28 Feb 2001 11:46:31 +0200 > >Hello All, >I have some questions regarding the ShiftIn and ShiftOut system calls. I >failed to find these details in the BX documentation >In what order are the bits sent with the ShiftOut procedure? Similar: what >position do incoming bits occupy into the byte returned by the ShiftIn >function? Also, are any remaining bits of the byte padded with zeros or >left >to their earlier values? >What is the duration of the clock hi and lo pulse? I understand its cycle >is >in the 1-2us order, to be compatible with 400 kHz systems - but how long is >it exactly? Can it be adjusted? >Thanks in advance. >Geroge Chamilothoris _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com |