On Thu, 5 Mar 1998 20:42:22 -0600, you wrote: >I'm pretty new to this so bear with me. >Here is a snippet of code that I have come up with to >immulate the "SHIFTIN" function of the Basic Stamp 2 >A professional opinion would be appreciated >Routine follows: > > movlw 0x08 ; set for 8 bits > movwf count > clrf Byte_in ; set to all 0's > clrc >IN bsf clk ; set clock pin high > nop ; may not need these > nop ; don't want to over speed > btfsc Data_pin ; Is bit 1 or 0 ? > setc ; set carry if it is 1 > rlf Byte_in ; MSB first, data in > bcf clk ; clock low > decfsz count ; done 8 bits ? > goto IN ; no > return > >It looks to me like it will work but I don't have the expertise. >Of course the best would be just to burn it and test it. The >problem is that I have so much more to test that I would like >some code that works to cut down on my fumble fingered >debugging ! > Thanks in advance > James a slightly smaller version... movlw 1 ; end of byte marker movwf byte_in loop bsf clk goto $+1 ; 2-cycle NOP (if needed) clc btfsc data_pin sec bcf clk ; clear clk as soon as data has been read ; to allow maximum time for clk fall rlf byte_in skpc ; loop until marker bit falls out end of byte goto loop if you can arrange for data_in to be bit 0 or 7 of a port, you can read it into carry using rrf port,w or rlf port,w respectively. ____ ____ _/ L_/ Mike Harrison / White Wing Logic / wwl@netcomuk.co.uk _/ L_/ _/ W_/ Hardware & Software design / PCB Design / Consultancy _/ W_/ /_W_/ Industrial / Computer Peripherals / Hazardous Area /_W_/