Are SDO and SCK both set as output (0) in the TRIS register? > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of K=FCbek Tony > Sent: Thursday, February 07, 2002 5:45 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]: 18c452 - Master mode SPI sends no data > > > Hi, > here are some code that works on an 16F87x, should be minor > differences with the 18xx. > Although it uses fsr to access the config regs ( not > advicable by Mchip ) > I don't se any reason for it not to work. > > /Tony > > > ; > ************************************************************** > ********* > ; > ; INIT_SPI - Initialises SPI, module, full speed, master > mode, idle clock > low > ; does NOT enable SPI interrupts ( use polling ) > ; Can be at any bank at entry, leaves ram bank setting > intact at exit. > > INIT_SPI > ; make sure pins are setup before calling this routine > ; TRISC:5 and TRISC:3 must be cleared ( as for input, > but operates > as outputs ) > ; furthermore its advised that interrupts are > disabled during this > routine > > ; setup SPI status reg > MOVLW SSPSTAT ; get adress for synch serial port status reg > MOVWF FSR ; setup fsr > MOVLW 0x00; (1< MOVWF INDF ; and store it > > ; setup SPI control reg > MOVLW SSPCON ; get adress for synch serial port control reg > MOVWF FSR ; setup fsr > MOVLW ((1< syncronous port, > idle clock is high,speed XTAL/16 > MOVWF INDF ; and set it > > > ; make sure SPI interrupts are disabled > MOVLW PIE1 ; get adress for periphial irq's > MOVWF FSR ; setup fsr > BCF INDF,SSPIE ; 'disable' reciever irq > > RETURN > > ; > ************************************************************** > ********* > ; > ; SPI_XFER_BYTE - sends ( and receives ) one byte , by using h/w SPI > ; Byte to send in W, returns with received data in W > ; > SPI_XFER_BYTE > MOVWF SSPBUF ; put out byte for sending > ; initiate an send seq. > MOVLW SSPSTAT ; get adress for SPI status > MOVWF FSR ; setup FSR > SPI_XFER_LOOP > BTFSS INDF,BF ; check for tx complete > GOTO SPI_XFER_LOOP ; nope > MOVF SSPBUF,W ; get received byte > RETURN ; and return > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics