1200_spi_routines.a51

来自「此程序是MSC1203工程评估板MCU原代码.此芯片精度高.内部包含MCU」· A51 代码 · 共 49 行

A51
49
字号
$NOMOD51
$include (REG1200.INC)

PUBLIC _spim_send_recv_byte
spim_routines  	SEGMENT  CODE
	RSEG	spim_routines

ONEMICROSEC MACRO
	NOP
	NOP
ENDM

FIVEMICROSEC MACRO
	ONEMICROSEC
	ONEMICROSEC
	ONEMICROSEC
	ONEMICROSEC
	ONEMICROSEC
ENDM	

spim_send_1clk:
	setb	P3.6		;SCLK=1
	ONEMICROSEC
	clr	P3.6  	;SCLK=0
	ONEMICROSEC
ret	

spim_send_8clk:
	mov r0, #08h
next_clk:
	setb	P3.6		;SCLK=1
	ONEMICROSEC
	clr	P3.6	  	;SCLK=0
	ONEMICROSEC
	djnz r0,	next_clk
ret



_spim_send_recv_byte:
   mov SPIDATA, r7				; Clears the SPIIRQ and also sets the data register with the address
	acall spim_send_8clk			; Send 8 clock cycles
	mov r7, SPIDATA		      ; Clears the SPIIRQ and also reads the received byte.
ret		


end 		

⌨️ 快捷键说明

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