⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spi.asm

📁 Training embedded apps to process speech may be as easy as finding the right 8-bit micro. Don t let
💻 ASM
字号:
; Routine assumes that previous code checks for Chip Select low
; Only transmitting/receiving 8-bits at a time, transmit data is
; written into SPIData register, receive data is returned in SPIData
; Clock polarity can be changed in lines 4 & 12
; SCK, SDI, and SDO are defines of specific pins on I/O ports supplied
; by the user
SPIRxTx
    	movlw   0x08            ; Place bit count value into W
    	movwf   BitCount        ; W -> BitCount for counting bits
LoopData
	bcf	  STATUS,C		; Assume we are receiving a ZERO
	btfss	  SCK			; Wait for clock to go high
	goto	  $-1			; Go back one instruction
    	btfsc   SDI             ; Skip if we are receiving a ZERO
    	bsf     STATUS,C        ; Receive a ONE from the SDA line
    	rlf     SPIData,F       ; Rotate received bit into Low digit
    	bcf     SDO             ; Assume we are transmitting a ZERO
    	btfsc   STATUS,C        ; Skip if we are sending a ZERO
    	bsf     SDO             ; Transmit a ONE onto the SDO line
	btfsc	  SCK			; Wait for clock to go low
	goto	  $-1			; Go back one instruction
    	decfsz  BitCount,F      ; Skip if we have XMIT/RCV all 8 bits
    	goto    LoopData        ; Not done yet so loop back for next bit
    	return                  ; DONE receiving/xmiting - GO HOME! 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -