📄 lf_pwm.asm
字号:
;------------------------------------------------------------------------------+
LF.Send_Clamp_One
AFE.SendCMDClampON
Delay.WaitFor LF.T_STEP,'u'
AFE.SendCMDClampOFF
Delay.WaitFor LF.T_STEP, 'u'
return
; ***********************************************************************
; Send_Clamp_Zero()
; ***********************************************************************
;------------------------------------------------------------------------------+
; |
; LF.Send_Clamp_Zero() |
; |
;------------------------------------------------------------------------------+
; |
; This method sends a zero over the LF antenna. |
; |
; |
; |
; Used SFRs: |
; Delay.Returned |
; |
; |
; Calls subroutines: |
; AFE.SendCMDClampON |
; SPI.Write |
; Delay.WaitFor |
; AFE.SendCMDClampOFF |
; SPI.Write |
; |
; |
; Stacklevel: 2 |
; |
;------------------------------------------------------------------------------+
LF.Send_Clamp_Zero
AFE.SendCMDClampON
Delay.WaitFor LF.T_STEP, 'u'
AFE.SendCMDClampOFF
Delay.WaitFor 2*LF.T_STEP, 'u'
return
; ***********************************************************************
; * AFE Receive Routine *
; ***********************************************************************
;------------------------------------------------------------------------------+
; |
; w LF.Receive8() |
; |
;------------------------------------------------------------------------------+
; |
; This method receives one byte over the LF-AFE |
; |
; |
; Returns: |
; w - The received data byte |
; |
; |
; Used SFRs: TMR0 PORTC |
; |
; |
; Stacklevel: 2 |
; |
;------------------------------------------------------------------------------+
LF.Receive8
banksel OPTION_REG
movlw PRE_BITS ; SET UP FOR TMR0'S PRESCALER VALUE TO 1:8
; (RAPU, bit7) = 0 to enable weak pull-up for PortA also
MOVWF OPTION_REG
banksel TMR0
clrf TMR0 ; Rising edge detected, Reset Timer
banksel LF.Buffer
clrf LF.Buffer ; clear receive register
clrf LF.Parity
bcf INTCON,T0IF ; Reset Timer #0 Interrupt Flag
movlw .8 ; number of bits to receive
movwf LF.COUNTER ; load number of bits into counter register
ReceiveNext
call LF.DetectFalling
btfsc STATUS,Z
retlw 0x00
ReceiveNext2
call LF.DetectRising
btfsc STATUS,Z
goto Return.Fail
btfsc INTCON,T0IF
goto Return.Fail
movlw (3*LF.T_PERIOD_MAX)/(4*PRESCALER*LF.T_INST);0x9C ; Determine Bit value Time>156, then Zero else One
subwf Time,w
banksel LF.Buffer
movf LF.COUNTER,w
btfsc STATUS,Z
goto ParityCheck
btfsc STATUS,C
incf LF.Parity,f
rrf LF.Buffer,f ; Rotate bit received bit, now in carry, into receive buffer
; banksel LF.COUNTER
decf LF.COUNTER, f ; Decrement receive count register by one
goto ReceiveNext ; ... no, then receive next bit
ParityCheck
btfss STATUS,C
goto Receive.ParityZero
; goto Receive.ParityOne
Receive.ParityOne
btfss LF.Parity,0
goto Receive.Success
goto Return.Fail
Receive.ParityZero
btfsc LF.Parity,0
goto Receive.Success
goto Return.Fail
; banksel LF.Buffer
Receive.Success
movf LF.Buffer,w ; Move received data byte into WREG
bcf STATUS,Z
return
;------------------------------------------------------------------------------+
; |
; LF.ReadBuffer( w FSR ) |
; |
;------------------------------------------------------------------------------+
; |
; This method reads an specified amount of bytes from the LF-Input to a |
; buffer. |
; The buffer has to be within bank0 or bank1. |
; |
; |
; Parameters: |
; w - The amount of bytes to be read |
; FSR - The start address of the buffer |
; |
; |
; |
; Used SFRs: |
; |
; |
; Calls subroutines: |
; AFE.Receive8 |
; |
; |
; Stacklevel: 1 |
; |
; |
; Example: |
; movlw InputBuffer |
; movwf FSR |
; movlw 0x04 |
; call AFE.ReadBuffer |
; |
; |
; Description: |
; This reads 4 bytes from the LF-Input to the buffer "InputBuffer" |
; |
;------------------------------------------------------------------------------+
LF.ReadBuffer
banksel LF.TEMP
movwf LF.TEMP
call LF.DetectRising ;Adjusting delay of first bit
LF.ReadBuffer.loop
call LF.Receive8
btfsc STATUS,Z
goto Return.Fail
bankisel PORTA
movwf INDF
incf FSR,f
decfsz LF.TEMP,f
goto LF.ReadBuffer.loop
bcf STATUS,Z
return
; ***********************************************************************
; * AFE Send Byte Routine *
; ***********************************************************************
;------------------------------------------------------------------------------+
; |
; LF.Send8() |
; |
;------------------------------------------------------------------------------+
; |
; This method transmits one byte over the LF-AFE |
; |
; |
; |
; Used SFRs: Delay.Returned |
; |
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -