PIC Microcontoller SPI Input / Ouput Method

16C73 SPI Slave Mode

Josef Hanzal, M. S. [snail at iol.cz] of Snail Instruments +420-311-624433 says:

I have used SPI on PIC16C73 in slave mode to catch data sent to MAX7213 LED display driver. As far as I remember, it worked without much troubles. Extracted code below. The underscored bit names are #defines including the proper register, like #define _C STATUS,0


 CBLOCK __GPRAM
        TEMPW, TEMPS, TEMPF
        FLAGS ...
        SSPADR...
        ....
 ENDC
 CBLOCK 0x60
        SSPDAT:SSPBLEN
 ENDC

#define _FSSPDT FLAGS,6

; ================================================================
; INTERRUPT--INTERRUPT--INTERRUPT--INTERRUPT--INTERRUPT--INTERRUPT
; ================================================================
        ORG     4
        _INT_SAVE_REG TEMPW, TEMPS
SSPINT: BTFSS   _SSPIF
        GOTO    INTER
        BCF     _SSPIF
        BTFSC   _FSSPDT         ;flag indicates if address or data
        GOTO    SSPI0           ;was received, it is MAX7213 specific
        MOVF    SSPBUF,W
        ADDLW   SSPDAT
        MOVWF   SSPADR
        BSF     _FSSPDT
        GOTO    IEND
SSPI0:  MOVFF   FSR,TEMPF
        MOVFF   SSPADR,FSR
        MOVFF   SSPBUF,INDF
        MOVFF   TEMPF,FSR
        GOTO    IEND
INTER:  BTFSS   _INTF           ;RB0 connected to CS of Maxim
        GOTO    IEND
        BCF     _INTF
        BCF     _FSSPDT
        BSF     _FDSUPD
        ;GOTO   IEND
IEND:   _INT_RESTORE_REG TEMPW,TEMPS
        RETFIE

SPI inicialization:

 LDB    SSPCON,B'00110101'      ;ENABLE SPI SLAVE, RECEIVE ON RISING EDGE
 LDB    RCSTA,1<<SPEN|1<<CREN   ;ENABLE RECEIVE, ENABLE SERIAL ASYNC. COMM.

Macros:
 MOVFF S,D =  MOVF S,W; MOVWF D
 LDB F,K   =  MOVLW K; MOVWF F


Questions: