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

📄 lf_pwm.asm

📁 汽车无钥进入系统设计,基于PIC单片机16F639,包括电路图和源码
💻 ASM
📖 第 1 页 / 共 3 页
字号:
;------------------------------------------------------------------------------+
;                                                                              |
;    Module LF_pwm                                                             |
;                                                                              |
;------------------------------------------------------------------------------+
;                                                                              |
;    LF_PWM.asm                                                                |
;    Jan Ornter                                                                |
;    DATE:   11-9-2005                                                         |
;    VER.:   1.0                                                               |
;    This class implements the LF transmission protocoll.                      |
;    It uses the commands of the AFE to modulate the data via LF-Talkback on   |
;    the carrier signal.                                                       |
;    The following diagrams visualize the coding of the data.                  |
;                                                                              |
;                                                                              |
;     A coded '0'                                                              |
;         |<  T_STEP  >|<        2*T_STEP        >|                            |
;          ____________                                                        |
;        _|            |__________________________|                            |
;------------------------------------------------------------------------------+
#include Project.inc
#include Delay.inc
#include SPI.inc
#include AFE_639.inc
	ifndef LF.PORT
;------------------------------------------------------------------------------+
;                                                                              |
;    Constant LF.PORT                                                          |
;                                                                              |
;------------------------------------------------------------------------------+
;                                                                              |
;    The port, the LF data input is connected to.                              |
;    You may override the default value by either defining the same constant   |
;    in your Project.inc file or by changing the default value in the module's |
;    source.                                                                   |
;                                                                              |
;                                                                              |
;------------------------------------------------------------------------------+
#define LF.PORT		PORTC
	endif
	ifndef LF.PIN
;------------------------------------------------------------------------------+
;                                                                              |
;    Constant LF.PIN                                                           |
;                                                                              |
;------------------------------------------------------------------------------+
;                                                                              |
;    The pin, the LF data input is connected to.                               |
;    You may override the default value by either defining the same constant   |
;    in your Project.inc file or by changing the default value in the module's |
;    source.                                                                   |
;                                                                              |
;                                                                              |
;------------------------------------------------------------------------------+
#define LF.PIN		3
	endif
#define	LFDATA		LF.PORT,LF.PIN		; Low Frequency Data IN
	ifndef LF.T_PERIOD_MAX
;------------------------------------------------------------------------------+
;                                                                              |
;    Constant LF.T_PERIOD_MAX                                                  |
;                                                                              |
;------------------------------------------------------------------------------+
;                                                                              |
;    The maximum period of one bit - the period of a '0' - in multiples of 100 |
;    ns.                                                                       |
;    You may override the default value by either defining the same constant   |
;    in your Project.inc file or by changing the default value in the module's |
;    source.                                                                   |
;                                                                              |
;                                                                              |
;------------------------------------------------------------------------------+
#define LF.T_PERIOD_MAX	.8000
	endif
	ifndef LF.T_INST
;------------------------------------------------------------------------------+
;                                                                              |
;    Constant LF.T_INST                                                        |
;                                                                              |
;------------------------------------------------------------------------------+
;                                                                              |
;    The instruction time in multiples of 100 ns.                              |
;    You may override the default value by either defining the same constant   |
;    in your Project.inc file or by changing the default value in the module's |
;    source.                                                                   |
;                                                                              |
;                                                                              |
;------------------------------------------------------------------------------+
#define LF.T_INST		.5
	endif
	ifndef LF.T_NOISE_MAX
;------------------------------------------------------------------------------+
;                                                                              |
;    Constant LF.T_NOISE_MAX                                                   |
;                                                                              |
;------------------------------------------------------------------------------+
;                                                                              |
;    The maximum time of spikes, that should be surpressed, in multiples of 100|
;     ns.                                                                      |
;    You may override the default value by either defining the same constant   |
;    in your Project.inc file or by changing the default value in the module's |
;    source.                                                                   |
;                                                                              |
;                                                                              |
;     Example                                                                  |
;          |< Noise (t<T_NOISE_MAX) >|      |<      Edge (t>T_NOISE_MAX)       |
;           >|                                                                 |
;           _________________________                                          |
;           _______________________________________                            |
;        __|                         |______|                                  |
;------------------------------------------------------------------------------+
#define LF.T_NOISE_MAX	.200
	endif
	ifndef LF.T_STEP
;------------------------------------------------------------------------------+
;                                                                              |
;    Constant LF.T_STEP                                                        |
;                                                                              |
;------------------------------------------------------------------------------+
;                                                                              |
;    This time adjusts the bitrate of transferred data.                        |
;    The value is in micro seconds and has to be a multiple of 50.             |
;    You may override the default value by either defining the same constant   |
;    in your Project.inc file or by changing the default value in the module's |
;    source.                                                                   |
;                                                                              |
;                                                                              |
;     A coded '0'                                                              |
;         |<  T_STEP  >|<        2*T_STEP        >|                            |
;          ____________                                                        |
;        _|            |__________________________|                            |
;------------------------------------------------------------------------------+
#define LF.T_STEP		.250
	endif
	udata
LF.Buffer		res 1
LF.COUNTER		res 1
LF.TEMP			res 1
Counter			res 1
Time			res 1
LF.Parity		res 1
	global	LF.Send8, LF.Receive8, LF.ReadBuffer, LF.SendBuffer
	variable PRE_BITS = B'00000000'
	variable TMP_PRESCALER = ( LF.T_PERIOD_MAX / (.220 * LF.T_INST) ) + .1
	variable PRESCALER = .2
	if ( TMP_PRESCALER == .1)
PRE_BITS = B'00001000'
PRESCALER = .1
	else
PRE_BITS = B'00000000'
		while(PRESCALER < TMP_PRESCALER)
PRE_BITS+=.1
PRESCALER*=.2
		endw
		if(PRE_BITS>0x07)
			error Can not setup correct prescaler
		endif
	endif
	messg Setting Prescaler value of #v(PRESCALER) #v(PRE_BITS)
	code
; ***********************************************************************	
; Send_Clamp_One()
; ***********************************************************************
;------------------------------------------------------------------------------+
;                                                                              |
;    LF.Send_Clamp_One()                                                       |
;                                                                              |
;------------------------------------------------------------------------------+
;                                                                              |
;    This method sends a one over the LF antenna.                              |
;                                                                              |
;                                                                              |
;                                                                              |
;    Used SFRs:                                                                |
;    Delay.Returned                                                            |
;                                                                              |
;                                                                              |
;    Calls subroutines:                                                        |
;    AFE.SendCMDClampON                                                        |
;        SPI.Write                                                             |
;    Delay.WaitFor                                                             |
;    AFE.SendCMDClampOFF                                                       |
;        SPI.Write                                                             |
;                                                                              |
;                                                                              |
;    Stacklevel: 2                                                             |
;                                                                              |

⌨️ 快捷键说明

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