java怎么拦截某个对象
278
2022-10-27
PIC单片机的IIC接口程序
;************************************************************GetData bsf Rcv_Progress ; set Bus status for txmt progress bcf Rcv_Success ; reset status bit movlw 0x08 movwf I2CBitCountRcvNextBit bsf STATUS, RP0 ; page 1 for TRIS manipulation bcf _SCL ; lower clock bcf _SDA ; lower data line call Delay47uSec ; guarantee min LOW TIME tLOW & setup time bsf _SCL ; clock high, data sent by slave call Delay40uSec ; guarantee min HIGH TIME tHIGH bcf STATUS, RP0 ; select page 0 to read Ports bcf STATUS, C ; 0 out Status btfsc SdaPin ; Check state of pin bsf STATUS, C ; Pin was high, set status rlf I2CData, F ; left Shift data (MSB first) decfsz I2CBitCount, F ; Are we done yet goto RcvNextBit ; Nope, go get the next one;; Generate ACK bit if not last byte to be read,; if last byte Gennerate NACK ; do not send ACK on last byte, main routine will send a STOP bit; bsf STATUS, RP0 ; Page 1 for TRIS manipulation bcf _SCL ; pull SCL low bcf _SDA ; ACK by pulling SDA low btfsc Last_Byte_Rcv ; Is it the last byte to receive bsf _SDA ; If so, send NACK by setting SDA high call Delay47uSec ; guarantee min LOW TIME tLOW & Setup time bsf _SCL ; Raise Clock back up call Delay40uSec ; guarantee min HIGH TIME tHIGHRcvEnd: bcf _SCL ; reset clock bcf Rcv_Progress ; reset bit in Bus Status bsf Rcv_Success ; transmission successful bcf ACK_Error ; ACK OK return
Delay47uSec: movlw ((_47uS_Delay-5)/3 + 1) ; move delay into WDlyK movwf DelayCount ; move what is in W to DelayCount decfsz DelayCount, F ; Decrement DelayCount goto $-1 ; Loop until 0 return ; return
Delay40uSec: movlw ((_40uS_Delay-8)/3 + 1) ; move delay into W goto DlyK ; goto DlyK loop
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~