I am working on a simple emulation of an old PlayStation controller. I have two switches sw1 and sw2 connected to ra0 and ra1 both are active high and pulled down via 10k pulldowns. The two switches are mapped to "up" and "down" bits of the first data byte. The protocol is just SPI with added ATT and ACK lines. The PlayStation did not respond, under inspection of the logic analyzer the data line acts sporadic. http://old.nabble.com/file/p31243196/2njepub.jpg=20 code: LIST p=3D16F648a ;tell assembler what chip we are using #include "P16F648a.inc" ;include the defaults for the chip __config 0x3D18=09 =09 =20 #define sw1 PORTA,0 #define sw2 PORTA,1 #define psx_dat PORTB,5 #define psx_cmd PORTB,1 #define psx_att PORTB,2 #define psx_clk PORTB,3 #define psx_ack PORTB,4 cblock 0x20 bit_count ;for counting to 8 in spi loop temp_out ;regester to be shifted out spi temp_in ;regester to be shifted in spi psxbutton0=09 psxbutton1 endc org 0x00 goto Start INTserv org 0x04 =20 Start Setup movlw 0x07 movwf CMCON ;comparitors off banksel TRISA ;select bank 1 movlw b'10000000' movwf OPTION_REG ;pullups off movlw b'11' =09 movwf TRISA ;ra0 and one input movlw b'001110' =09 movwf TRISB banksel PORTA ;select bank 0 movlw 0xff movwf PORTB clrf PORTA movlw 0xff movwf psxbutton0 movwf psxbutton1 Detect btfsc psx_att ;wait for att line to go low goto $-1 Scan ;scan sw1 and sw2 and map them to "up" and "down" on the pad bsf psxbutton0,6;preset button down btfsc sw1 ;skip if button is not pressed bcf psxbutton0,6 ;clear if it is pressed bsf psxbutton0,4 btfsc sw2 bcf psxbutton0,4 =09 movlw 0xff;idol call PSX_SPI call Ack movlw 0x41 call PSX_SPI call Ack movlw 0x5a call PSX_SPI call Ack movfw psxbutton0 call PSX_SPI call Ack movfw psxbutton1 call PSX_SPI goto Detect=09 PSX_SPI ;sends contents of w LSB first over psx_dat returns psx_cmd in = w=20 movwf temp_out movlw 0x08 movwf bit_count Clk_in_out btfsc psx_clk ;wait for line to fall goto $-1 rrf temp_out;clock rotate byte into carry flag btfss STATUS,C ;if low bcf psx_dat ;set low btfsc STATUS,C ;if high bsf psx_dat ;set high btfss psx_clk ;wait for clock to go high to sample psx_cmd goto $-1 bsf STATUS,C ;preset carry flag btfss psx_cmd ;if psx_cmd is high than skip bcf STATUS,C ;if low clear carry bit rrf temp_in ;roll carry bit into temp_in decfsz bit_count ;eight counts yet? goto Clk_in_out ;if not clock another bit movfw temp_in ;else return bsf psx_dat ;make sure data line is pulled high again return =09 Ack bcf psx_ack=09 goto $+1 ;3us pause nop bsf psx_ack return end "When the PSX wants to read information from a controller it pulls that devices ATT line low and issues a start command (0x01). The Controller Will then reply with its ID (0x41=3DDigital, 0x23=3DNegCon, 0x73=3DAnalogue Red = LED, 0x53=3DAnalogue Green LED). At the same time as the controller is sending t= his ID byte the PSX is transmitting 0x42 to request the data. Following this th= e COMMAND line goes idle and the controller transmits 0x5A to say "here comes the data". After this command initiation proccess the controller then sends all its data bytes (in the case of a digital controller there is only two). After the last byte is sent ATT will go high and the controller does not need to ACK."=20 Thank you. -Eric --=20 View this message in context: http://old.nabble.com/Software-SPI-help-tp312= 43196p31243196.html Sent from the PIC - [PIC] mailing list archive at Nabble.com. --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .