DatasheetQ Logo
Electronic component search and free download site. Transistors,MosFET ,Diode,Integrated circuits

LS7366R View Datasheet(PDF) - LSI Corporation

Part Name
Description
Manufacturer
LS7366R Datasheet PDF : 13 Pages
First Prev 11 12 13
;Sample routines for PIC18CXXX interface
/***********************************************************************************************************************/
;Initialize PIC18Cxxx portc in LS7366 compatible SPI
;Setup: master mode, SCK idle low, SDI/SDO datashift on high to low transition of SCK
;SS/ assertion/deassertion made with direct manipulation of RA5
;Initialize portc
CLRF
CLRF
MOVLW
MOVWF
BCF
BSF
CLRF
BSF
MOVLW
MOVWF
PORTC
LATC
0x10
TRISC
TRISA, 5
PORTA, 5
SSPSTAT
SSPSTAT, CKE
0x21
SSPCON
;Clear portc
;Clear data latches
;RC4 is input, RC3 & RC5 are outputs
;RC3=CLK, RC4=SDI, RC5=SDO
;RA5=output
;RA5=SS/=high
;SMP=0 => SDI data sampled at mid-data
;CKE=1 => data shifts on active to idle SCK transitions
;SPI mode initialization data
;Master mode, CLK/16, CKP=0 => CLK idles low
;data shifted on active to idle CLK edge
/***********************************************************************************************************************/
; WR_MDR0
LOOP1
LOOP2
BSF
BCF
MOVLW
MOVWF
BTFSS
BRA
MOVF
MOVLW
MOVWF
BTFSS
BRA
BSF
PORTA, 5
PORTA, 5
0x88
SSPBUF
SSPSTAT, BF
LOOP1
SSPBUF, W
0xA3
SSPBUF
SSPSTAT, BF
LOOP2
PORTA, 5
;SS/=high
;SS/=low
;LS7366 WR_MDR0 command
;Transmit command byte
;Transmission complete with BF flag set?
;No, check again
;Dummy read to clear BF flag.
;MDR0 data:fck/2, synchronous index. index=rcntr, x4
;Transmit data
;BF set?
;No, check again
;SS/=high
/***********************************************************************************************************************/
;RD_MDR0
LOOP1
LOOP2
BSF
BCF
MOVLW
MOVWF
BTFSS
BRA
MOVWF
BTFSS
BRA
MOVF
MOVWF
BSF
PORTA, 5
PORTA, 5
0x48
SSPBUF
SSPSTAT, BF
LOOP1
SSPBUF
SSPSTAT, BF
LOOP2
SSPBUF, W
RXDATA
PORTA, 5
;SS/=high
;SS/=low
;LS7366 RD_MDR0 command
;Transmit command byte
;BF flag set?
;No, check again
;Send dummy byte to generate clock & receive data
;BF flag set?
;No, check again
;Recieved data in WREG.
;Save received data in RAM
;SS/=high
7366R-041906-13

Share Link: 

datasheetq.com  [ Privacy Policy ]Request Datasheet ] [ Contact Us ]