Thank you Tony. I don't understand this: >Although it uses fsr to access the config regs ( not advicable by Mchip = ) what does it mean? Regards, Carlos -----Original Message----- From: K=FCbek Tony To: PICLIST@MITVMA.MIT.EDU Date: jueves 7 de febrero de 2002 13:30 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 clo= ck >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 operat= es >as outputs ) > ; furthermore its advised that interrupts are disabled during th= is >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<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