亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? can.asm

?? 運用單片機實現時序輸出,daddadasdad
?? ASM
?? 第 1 頁 / 共 2 頁
字號:
	call	SPI_WRITE

;	banksel	TXREG
;	movlw	0x33
;	movwf	TXREG
;	call	txwait

;+========================+
;| Main Sequence          |
;+========================+
	banksel	PORTB
	bsf	PORTB, 7	;Hit the power indicator

	clrf	PIR1
	clrf	PIR2


	banksel	TXREG
	movlw	INIT_MSG
	movwf	TXREG
	call	txwait


	banksel	INTCON
	bsf	INTCON, 6	;Enable peripheral interrupts
	bsf	INTCON, 7	;Enable global interrupts

mainloop

	; Okay, now let's take all those buffers we filled up and direct their data to where it
	; needs to go

	btfsc	CAN_RX0_READY
	call	READ_RXB0

	;Is there anything in the transmit buffer?
	;(I should really be using a flag for this instead!)
	banksel	CAN_buff_ctr
	movf	CAN_buff_ctr, F
	bz	checkPCbuffer

	banksel	CAN_buff_out
	movfw	CAN_buff_out
	movwf	FSR
	banksel	TXREG
	movfw	INDF		;Data
	movwf	TXREG
	
	banksel	CAN_buff_out
	movfw	CAN_buff_out	;Have we read beyond our alloted space?
	addlw	0x1F		; This will overflow if we've overflowed
	bnc	CANdecnormally	;branch-no-carry
	movlw	CAN_buff
	movwf	CAN_buff_out
	decf	CAN_buff_ctr
	goto	endservice
CANdecnormally
	incf	CAN_buff_out
	decf	CAN_buff_ctr	; I'm not checking for underflow, since we already checked


checkPCbuffer
	;Is there anything in the transmit buffer?
	banksel	PC_buff_ctr
	movf	PC_buff_ctr, F
	bz	endservice

	banksel	PC_buff_out
	movfw	PC_buff_out
	movwf	FSR
	banksel	TXREG
	movfw	INDF		;Data
	movwf	TXREG
	
	movfw	PC_buff_out	;Have we read beyond our alloted space?
	addlw	0xB0		; This will overflow if we've overflowed
	bnc	PCnormaldec	;branch-no-carry
	movlw	PC_buff
	movwf	PC_buff_out
	decf	PC_buff_ctr
	goto	endservice
PCnormaldec
	incf	PC_buff_out
	decf	PC_buff_ctr	; I'm not checking for underflow, since we already checked

endservice

	;Include any necessary clean-up here

	goto	mainloop


;+=========================+
;| Function Calls          |
;+=========================+

wait
	banksel	delay
	movlw	B'11100000'
	movwf	delay
del	decf	delay
	skpz
	goto	del
	return

txwait
	banksel	PIR1
txloop	btfss	PIR1, TXIF
	goto	txloop
	bcf	PIR1, TXIF
	return

SPI_WRITE	;Do NOT call until SPI has been configured!!!
	banksel	PORTB
	bcf	CAN_CS		;MCP2510's chip select line	

#ifdef	debug
	movlw	0x57
	movwf	TXREG		;Debugging message
#endif

	movlw	B'00000010'	;MCP2510 Write command

	banksel	SSPBUF
	movwf	SSPBUF

	movf	SSPBUF, W

	movfw	SPI1
	banksel	SSPBUF
	movwf	SSPBUF

	movf	SSPBUF, W

	movfw	SPI2
	banksel	SSPBUF
	movwf	SSPBUF

	movf	SSPBUF, W

;We've moved our three bytes, now let's go home
	banksel	PORTB
	bsf	CAN_CS
	return

BIT_MODIFY	;Do NOT call until SPI has been configured!!!
	banksel	PORTB
	bcf	CAN_CS		;MCP2510's chip select line	

#ifdef	debug
	movlw	0x42
	movwf	TXREG		;Debugging message
#endif

	movlw	B'00000101'	;MCP2510 Bitwise Modify
	banksel	SSPBUF
	movwf	SSPBUF

	movfw	SPI1
	banksel	SSPBUF
	movwf	SSPBUF

	movfw	SPI2
	banksel	SSPBUF
	movwf	SSPBUF
	
	movfw	SPI3
	banksel	SSPBUF
	movfw	SSPBUF

;We've edited the register, let's go back
	banksel	PORTB
	bsf	CAN_CS
	return

SPI_READ
	banksel	PORTB
	bcf	CAN_CS

#ifdef	debug
	movlw	0x52
	movwf	TXREG		;Debugging message
#endif

	movlw	B'00000011'	;MCP2510 Read command
	banksel	SSPBUF
	movwf	SSPBUF

	movwf	SPI1
	banksel	SSPBUF
	movwf	SSPBUF

;The next thing that comes in is the contents of that register.
; At this stage, nothing that comes from the 2510 is used by the PIC -- 
; it's just a straight pass-through

	banksel	SSPSTAT
rgo2	btfss	SSPSTAT, BF
	goto	rgo2

	banksel	SSPBUF
	movfw	SSPBUF
	banksel	SPIOUT
	movwf	SPIOUT

	banksel	PORTB
	bsf	CAN_CS
	
	return


READ_RXB0

;This function "calls up" the 2510, reads out the Data Length register, and loops that many
; times, feeding into the CAN_buff ring buffer.
;Right now, interrupts are turned OFF during the entire operation.  This is ridiculous.
; I bet that turning interrupts back on during any wait periods, or just briefly in between
; cycles would help a lot.
; The CLEVER way to do this would be to externally load an offset, since adding 0x10 to each of
;  these address bytes would select RXB1, instead.
; However, there is some doubt as to whether we will actually ever need RXB1.

	banksel	INTCON
	bcf	INTCON, 7	;OK, it's dumb, but it's temporary.

	banksel	PORTB
	bcf	CAN_CS		;Poke the 2510

	movlw	B'00000011'	;MCP2510 Read command
	banksel	SSPBUF
	movwf	SSPBUF

	movwf	RXB0DLC		;Address of RX Buffer 0's Data Length Code
	movwf	SSPBUF

;The next thing that comes in is the contents of that register.

	banksel	SSPSTAT
rxb01	btfss	SSPSTAT, BF
	goto	rxb01

	banksel	SSPBUF
	movfw	SSPBUF
	andlw	B'00001111'	;Mask out all but the bottom four bits
				; creating a nice loop timer
	banksel	loopctr0
	movwf	loopctr0
	bz	rxb0done	; It may be empty, in which case, don't waste time

	banksel	SSPBUF
	movlw	B'00000011'
	movwf	SSPBUF

	movlw	RXBUF0		;Address of start bit
	movwf	SSPBUF

rxb0loop
	banksel	PC_buff_in
	movfw	PC_buff_in
	movwf	FSR

	banksel	SSPSTAT
rxb0loopinner
	btfss	SSPSTAT, BF
	goto	rxb0loopinner

	banksel	SSPBUF
	movfw	SSPBUF

	banksel	CAN_buff
	movwf	INDF
	incf	CAN_buff_in
	movlw	CAN_buff_end
	xorwf	CAN_buff_in, W	;Is the new address out of bounds?
	skpz			;If it is, loop around
	goto	rb0_rest
	movlw	CAN_buff
	movwf	CAN_buff_in	;Loop around

rb0_rest
	incf	CAN_buff_ctr
	movlw	0x40		;64 bytes  -- HUGE counter
	xorwf	CAN_buff_ctr, W
	skpnz			;If the counter overflows, set the error bit
	bsf	CAN_BUFF_OVERFLOW

	banksel	loopctr0	;Decrement our counter, and see if we're done.
	decf	loopctr0
	bnz	rxb0loop

	bsf	CAN_BUFF_NOTEMPTY
rxb0done
	banksel	PORTB
	bsf	CAN_CS		;Do this before re-enabling interrupts, to prevent overflows

	banksel	INTCON
	bsf	INTCON, 7

	return	

CF_READY
	BTFSS	CF_RDY
	goto	CF_READY
	return

CF_READ
	call	CF_READY
	;Input from data lines
	banksel	TRISD
	movlw	0xFF
	movwf	TRISD
	banksel	PORTD
	clrf	PORTD

	bsf	CF_OE

; ********************************
; Handle incoming communications from the PC

PC_SERVICE	
	banksel	PC_buff_in
	movfw	PC_buff_in
	movwf	FSR

	banksel	RCREG
	movfw	RCREG

	; The following code grabs that byte from RCREG and puts it into the PC_buff buffer
	; When that buffer's counter is an integer multiple of eight, it gets flushed out
	; onto the CAN bus.

	movwf	INDF
	incf	PC_buff_in
	movlw	PC_buff_end
	xorwf	PC_buff_in, W	;Is the new address out of bounds?
	skpz			;If it is, loop around
	goto	pc_rest
	movlw	PC_buff
	movwf	PC_buff_in	;Loop around

pc_rest
	incf	PC_buff_ctr
	movlw	0x10		;16 bytes
	xorwf	PC_buff_ctr, W
	skpnz			;If the counter overflows, set the error bit
	bsf	PC_BUFF_OVERFLOW

	; At this point, we've loaded the new byte into the buffer, incremented the position
	; and checked for overflow.  We now indicate that the PC buffer contains data
	; and head back to IntService

	bsf	PC_BUFF_NOTEMPTY

	goto	CheckCAN


CAN_SERVICE
	;Since the MCP2510 generates an external interrupt for various things,
	; This routine needs to read off portb (To clear the interrupt)
	; Then poll the 2510 for the error.  If it IS a message, then a flag
	; should be set for the MAIN LOOP to read the buffer.  Don't do it here

	banksel	PORTB
	movf	PORTB, F	;Clear that interrupt
	bcf	CAN_CS

	movlw	B'00000011'	;MCP2510 Read command
	banksel	SSPBUF
	movwf	SSPBUF

	movwf	CANSTAT		;the 2510's status register
	banksel	SSPBUF
	movwf	SSPBUF

;The next thing that comes in is the contents of that register.
; We don't care about errors.  They aren't processed in listen mode, anyhow.

	banksel	SSPSTAT
CS2	btfss	SSPSTAT, BF
	goto	CS2

	banksel	SSPBUF
	movfw	SSPBUF
	andlw	B'00001110'

	banksel	PORTB
	bsf	CAN_CS

	xorlw	B'00001100'	;RXB0 Interrupt
	bnz	NextISR		;If anything else, then forget it.
	bsf	CAN_RX0_READY
	
	goto	NextISR

;+==========================+
;|  Interrupt Routines      |
;+==========================+

IntService

	movwf	W_TEMP		;save W, STATUS, PCLATH, and FSR
	swapf	STATUS, W
	movwf	STATUS_TEMP
	movfw	FSR
	movwf	FSR_TEMP
	movfw	PCLATH
	movwf	PCLATH_TEMP

	banksel	PIR1
	;Perform interrupt routines
CheckPC
	btfsc	PIR1, RCIF
	goto	PC_SERVICE
CheckCAN
	btfsc	PIR1, INTE
	goto	CAN_SERVICE
NextISR

	;Clear Receive errors
	bcf	RCREG, CREN
	bsf	RCREG, CREN
	bcf	PIR1,	RCIF

	;All done!  Now let's put everything back where it was
	movfw	PCLATH_TEMP
	movwf	PCLATH
	movfw	FSR_TEMP
	movwf	FSR
	swapf	STATUS_TEMP, W
	movwf	STATUS
	swapf	W_TEMP, F
	swapf	W_TEMP, W

	retfie

	end

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产精品黑人久久久| 成人免费黄色在线| 欧美日韩亚洲国产综合| 亚洲午夜在线电影| 欧美日韩精品一区二区天天拍小说 | 欧美三级日韩三级国产三级| 香蕉久久夜色精品国产使用方法 | 亚洲天堂2014| 欧美日韩高清在线播放| 欧美日韩国产一区二区三区地区| 亚洲国产精品天堂| 日韩三级高清在线| 国产丶欧美丶日本不卡视频| 国产精品福利在线播放| 欧美三级韩国三级日本三斤| 美女一区二区视频| 国产女人水真多18毛片18精品视频| 白白色 亚洲乱淫| 性做久久久久久免费观看| 91精品国产麻豆| 国产精品自在在线| 一区二区三区四区蜜桃| 精品区一区二区| 成人免费视频视频| 香蕉久久一区二区不卡无毒影院 | 国产欧美日韩综合精品一区二区| 91小视频免费观看| 蜜臀av性久久久久蜜臀av麻豆| 国产精品无码永久免费888| 欧美图片一区二区三区| 国产成人自拍网| 亚洲一二三区不卡| 国产视频一区二区三区在线观看| 色婷婷亚洲精品| 韩国女主播成人在线| 夜夜精品视频一区二区| 26uuu另类欧美亚洲曰本| 日本韩国精品一区二区在线观看| 精品一区二区在线免费观看| 亚洲精品中文字幕在线观看| 2021中文字幕一区亚洲| 在线观看国产一区二区| 国产99一区视频免费| 午夜久久久久久久久久一区二区| 亚洲国产高清不卡| 日韩一区二区三区四区五区六区| 91丨九色porny丨蝌蚪| 国内精品在线播放| 丝袜美腿亚洲综合| 亚洲精品免费在线观看| 国产日韩精品一区二区三区在线| 欧美一卡二卡在线观看| 在线一区二区三区四区| 成人av在线资源网| 国产一区二区美女| 免费在线一区观看| 亚洲国产视频网站| 亚洲免费在线看| 国产精品国产三级国产普通话三级| 日韩一区二区免费在线观看| 欧美日韩国产高清一区二区三区 | 中日韩av电影| 久久尤物电影视频在线观看| 欧美一区二区在线免费播放| 欧美亚州韩日在线看免费版国语版| 成人免费视频免费观看| 国产91高潮流白浆在线麻豆| 国产美女久久久久| 久久99久久99| 狠狠久久亚洲欧美| 精品一区二区在线看| 开心九九激情九九欧美日韩精美视频电影 | 日韩欧美123| 欧美日韩国产高清一区二区| 在线免费观看一区| 欧美日韩一区二区三区免费看| 色欧美88888久久久久久影院| 成人听书哪个软件好| 国产91色综合久久免费分享| 丰满白嫩尤物一区二区| 国产成人av一区二区三区在线 | 成人免费观看av| 懂色av一区二区夜夜嗨| 成人激情免费视频| 91一区二区在线| 91激情在线视频| 欧美日韩大陆在线| 欧美美女一区二区三区| 91精品婷婷国产综合久久性色| 欧美日韩精品一区二区天天拍小说 | 亚洲国产成人自拍| 自拍偷拍亚洲激情| 夜色激情一区二区| 午夜精品福利视频网站| 午夜精品一区二区三区电影天堂| 亚洲一区二区视频在线观看| 五月婷婷久久丁香| 麻豆国产精品视频| 国产福利91精品一区| a4yy欧美一区二区三区| 色婷婷av一区| 日韩欧美中文字幕制服| 国产亚洲美州欧州综合国| 亚洲少妇屁股交4| 亚洲一二三四在线观看| 久久精品国产精品亚洲综合| 国产精品主播直播| 欧亚一区二区三区| 欧美电影免费提供在线观看| 国产亚洲一区二区三区四区| 亚洲最大成人综合| 精品一区精品二区高清| 欧美日韩亚洲高清一区二区| 这里只有精品免费| 久久九九国产精品| 一区二区三区在线播放| 成人性生交大片免费看在线播放 | 精品国产不卡一区二区三区| 国产欧美一区二区精品仙草咪| 一区二区三区小说| 久草精品在线观看| 亚洲码国产岛国毛片在线| 美女国产一区二区| 91免费在线看| 精品久久久久久无| 亚洲色图在线视频| 精久久久久久久久久久| 在线视频国内自拍亚洲视频| 久久久亚洲精品一区二区三区| 亚洲综合久久久| 国产乱码精品一区二区三区av| 欧美综合天天夜夜久久| 国产女人水真多18毛片18精品视频| 天使萌一区二区三区免费观看| 成人黄色一级视频| 日韩欧美另类在线| 夜夜嗨av一区二区三区| av爱爱亚洲一区| xnxx国产精品| 日本欧美大码aⅴ在线播放| 91在线云播放| 久久久精品综合| 麻豆精品精品国产自在97香蕉| 欧美伊人久久大香线蕉综合69 | 欧美一区二区三区视频免费| 亚洲免费观看高清完整版在线| 国产精品一区2区| 欧美一区二区在线看| 午夜欧美电影在线观看| 日本伦理一区二区| 成人免费一区二区三区视频| 高清免费成人av| 国产婷婷色一区二区三区四区| 久久精品理论片| 日韩西西人体444www| 午夜欧美视频在线观看| 欧美日韩一级片在线观看| 一区二区免费在线| 91免费观看视频| 亚洲日本一区二区| 成人av在线资源网站| 国产精品不卡一区| 高清不卡一二三区| 国产欧美一区二区三区网站 | www.综合网.com| 欧美高清在线视频| av亚洲精华国产精华精| 国产欧美日韩在线视频| 国产精品一卡二卡| 亚洲国产高清不卡| 91污片在线观看| 亚洲一区二区三区四区中文字幕 | 日韩成人精品在线| 日韩亚洲欧美一区| 精品一区二区三区不卡 | 一区二区三区欧美在线观看| 一本大道久久a久久综合| 亚洲天天做日日做天天谢日日欢 | 亚洲色图欧洲色图婷婷| 一本色道久久综合亚洲aⅴ蜜桃 | 99久久久无码国产精品| 亚洲色图丝袜美腿| 欧美视频一区二区三区在线观看 | 亚洲成人午夜影院| 91精品国产综合久久久蜜臀粉嫩| 日韩电影在线观看网站| 精品福利二区三区| 国产成人精品一区二区三区网站观看 | 久久精品99国产精品| 国产视频一区二区三区在线观看| gogo大胆日本视频一区| 亚洲精品成人a在线观看| 欧美日韩国产精品自在自线| 麻豆高清免费国产一区| 国产日韩综合av| 欧美亚洲一区二区在线| 久久99国产精品久久99| 国产精品福利电影一区二区三区四区| 色天使色偷偷av一区二区| 麻豆精品国产传媒mv男同|