please dont rip this site

PIC Microcontoller SPI Input / Ouput Method

0/3540

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



file: /techref/microchip/16c73/spislave.htm, 2KB, , updated: 2006/4/7 21:07, local time: 2008/7/5 06:30,
TOP NEW HELP FIND: 
38.103.63.16:LOG IN
©2008 PLEASE DON'T RIP! DO: LINK / DIGG! / MAKE!

 ©2008 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it!
<A HREF="http://www.piclist.com/techref/microchip/16c73/spislave.htm"> PIC Microcontoller Input / Ouput Method - 16C73 SPI Slave Mode</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be reviewed) Just type in the box and press the Post button. (HTML welcomed!): A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Did you find what you needed?

  PICList 2008 contributors:
o List host: MIT, Site host massmind.org, Top posters @20080705 Apptech, Jinx, Xiaofan Chen, Alan B. Pearce, David VanHorn, Bob Axtell, William \Chops\ Westfield, Cedric Chang, olin piclist, Gerhard Fiedler,
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Shultz Electronics, Larry Williams, David VanHorn, Bryan Whitehouse, Timothy Weber, David Challis. Peter Todd. on-going support is MOST appreciated!
* Contributors: Neil Narwani, David Cary, Elemer AM Nyiry, Philip J Taylor, Gus Calabrese of Omegadogs.com, Gautama Venegas, Patrick B. Murphy, William Chops Westfield, Peter Todd, Leslie Ellis
  'What can I do?' - SiCKO

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .