"The (SLAVE SELECT) pin must NOT be driven LOW for the SS pin to function as an input." > Setup > ; port initialization > bcf STATUS,RP0 ; sets bank 0 > movlw b'00000000' <------ THIS IS DRIVING THE SS pin LOW!!! > movwf PORTA On 4 Jun 2002 at 17:50, Guillermo Rodriguez Garcia wrote: > Hello, > > I am using a PIC in slave mode with SS control enabled. I have > an ARM processor working as the SPI master that always sends > and receives 16 bits per transfer. When connecting the two > devices toghether, I have found that the first byte of each > transfer is always read by the PIC, but the second one is > ignored (it always reads $ff for the second byte). > > I thought I might need to cycle SS between bytes in a multi-byte > transfer but then I found out in the list that this was not > necessary. > > The SPI mode I'm using is: > > - PIC in slave mode, SS control enabled. > - CKP = 1, CKE = 1 > > I'm looking at the signals with a scope and they all look right. > However the PIC doesn't see the second byte in each transfer. > > I don't know what I may be doing wrong. Any suggestions? > > I'm attaching the code I use on the PIC, in case someone wants > to look at it. > > Thanks! > > > === Cut === > Startup > call Setup > > clrf SPICount > clrf SPIByte > > Main > ; SPI cycle > movlw b'10100101' ; write this byte ($a5) > movwf SSPBUF ; place data in buffer to send > > bsf STATUS, RP0 ; specify bank 1 > loop > btfss SSPSTAT, BF ; has data been received (xmit done)? > goto loop > > bcf STATUS, RP0 ; specify bank 0 > movf SSPBUF, W ; empty receive buffer > movwf SPIByte > incf SPICount, f > > next_1 > ; reset SPI just to be on the safe side > bcf SSPCON, SSPEN > bsf SSPCON, SSPEN > > goto Main ; loop forever > > > ;--------------------------------------------------------------------- > ; Setup > ; > ; Initializes program variables and peripheral registers. > ;--------------------------------------------------------------------- > > Setup > ; port initialization > bcf STATUS,RP0 ; sets bank 0 > movlw b'00000000' > movwf PORTA > movlw b'00000000' > movwf PORTB > > ; SPI setup > bsf STATUS,RP0 ; sets bank 1 > movlw 0x18 ; all bits are outputs except SDI and SCK > movwf TRISC > > bsf TRISA, 5 ; SS = input > > movlw b'01000000' ; SMP=0, CKE=1 > movwf SSPSTAT > > movlw b'00001110' > movwf ADCON1 ; set RA5 as digital I/O > > bcf STATUS,RP0 ; sets bank 0 > movlw 0x34 ; SPI enable, CKP=1, slave & SS enable > movwf SSPCON > > Setup_end > return > === Cut === > > > TIA, > G. > > -- > http://www.piclist.com#nomail Going offline? Don't AutoReply us! > email listserv@mitvma.mit.edu with SET PICList DIGEST in the body > > * | __O Thomas C. Sefranek tcs@cmcorp.com |_-\<,_ Amateur Radio Operator: WA1RHP (*)/ (*) Bicycle mobile on 145.41, 448.625 MHz ARRL Instructor, Technical Specialist, VE Contact. http://hamradio.cmcorp.com/inventory/Inventory.html http://www.harvardrepeater.org -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body