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

📄 e468.dt

📁 FM发射器的源代码,义隆MCU+三洋发射IC,LV2280方案.可实现睡眠,省电,发射频率88MHZ~108MHZ.
💻 DT
📖 第 1 页 / 共 2 页
字号:
	JBS KeyNum,4
	JMP SaveM3
	JBS KeyNum,5
	JMP SaveM4
	JBS KeyNum,6
	JMP PowerOff
	;JMP DispFreq
    JMP Key_Scan
KeyHoldDone2:
     CALL Delay_100ms
	JBS KeyNum,1
	JMP IncFreq           ;Freq++
	JBS KeyNum,0
	JMP DecFreq           ;Freq--
	JMP Key_Scan
;-------------------------Long Key M1,M2,M3,M4 ------------------
QuickAdd:
QuickDec:
    BS WORKFLAGS,KeyHold
    JMP Key_Scan
SaveM1:
    MOV DispFreqTmp_Hi,DispFreq_Hi
    MOV DispFreqTmp_Lw,DispFreq_Lw
    MOV DispFreq_Hi,M1_Value_Hi    ;SAVE DISPLAY FREQ TO M1_Value
	MOV DispFreq_Lw,M1_Value_Lw
	BS  DISPFLAGS,M1on
	JMP Dis_ON
SaveM2:
    MOV DispFreqTmp_Hi,DispFreq_Hi
    MOV DispFreqTmp_Lw,DispFreq_Lw
    MOV DispFreq_Hi,M2_Value_Hi    ;SAVE DISPLAY FREQ TO M2_Value
	MOV DispFreq_Lw,M2_Value_Lw
	BS  DISPFLAGS,M2on
	JMP Dis_ON
SaveM3:
    MOV DispFreqTmp_Hi,DispFreq_Hi
    MOV DispFreqTmp_Lw,DispFreq_Lw
    MOV DispFreq_Hi,M3_Value_Hi    ;SAVE DISPLAY FREQ TO M3_Value
	MOV DispFreq_Lw,M3_Value_Lw
	BS  DISPFLAGS,M3on
	JMP Dis_ON
SaveM4:
    MOV DispFreqTmp_Hi,DispFreq_Hi
    MOV DispFreqTmp_Lw,DispFreq_Lw
    MOV DispFreq_Hi,M4_Value_Hi    ;SAVE DISPLAY FREQ TO M4_Value
	MOV DispFreq_Lw,M4_Value_Lw
	BS  DISPFLAGS,M4on
	JMP Dis_ON
PowerOff:
    BS WORKFLAGS,LongKeyOn
	NOP
	JMP Key_Scan

;=================================
WriteLV2280:
	BS PORT8,2          ;LV2280 PWR ON 
	JMP  $+1
    CALL Delay_1ms
	mov	a,@0xd0
	call	IICStart
	call	IICSendByte	
	call	IICRecAck
		
	mov 	a,ControlByte1
	call	IICSendByte	
	call	IICRecAck
	
	mov     a,ControlByte2
	call	IICSendByte	
	call	IICRecAck
	
	call	IICStop
;	call	delay_5ms	
	CALL Delay_1ms
	ret
;=================================

ReadChar:
	mov	a,@0xA0
	call	IICStart
	call	IICSendByte	
	call	IICRecAck
	
	mov	 a,IICaddress
	call	IICSendByte
	call	IICRecAck

	mov	 a,@0xA1
	call	IICStart
	call	IICSendByte
	call	IICRecAck
	
	call	IICReceiveByte
	call	IICNoAck
	call	IICStop
	ret
;=================================
;=================================
;  
;  DispFrq_Hi,DispFreq_Lw -> Freq_Hi(0x1D) ,Freq_Lw(0x1E)
;   example:     1080 Mhz ->  0x04, 0x38
;=================================
DispFreq_Change:
 mov		a,DispFreq_Lw ;
 mov		0x20,a
 mov		a,DispFreq_Hi ;
 mov		0x21,a		;赋值 
 mov		a,0x20
 and		a,@0x0f
 mov		0x22,a
 swapa  	0x20
 and		a,@0x0f
 mov		0x23,a
 mov		a,0x21
 and		a,@0x0f
 mov		0x24,a
 swapa  	0x21
 and		a,@0x0f
 mov		0x25,a		;BCD码展开后存于0X22,0X23,0X24,0X25

 mov		a,0x25		;0X25为最高位 
 mov		0x30,a
 mov		a,@0x0		;多字节加法高位为0
 mov		0x31,a
 mov		a,0x24
 mov		0x32,a
 call		a_b		;调子程 
 mov		a,0x23
 mov		0x32,a
 call		a_b
 mov		a,0x22
 mov		0x32,a
 call		a_b
 ret

a_b:
 mov		a,@0x0		;0X34,0X35存储中间结果 
 mov		0x34,a
 mov		0x35,a
 mov		a,@0x0a		;实现乘10
 mov		0x33,a
a1:		
 mov		a,0x35		;两字节二进制加法,在本例中高字节肯定无进位 
 add		a,0x31
 mov		0x35,a
 mov		a,0x34
 add		a,0x30
 mov		0x34,a
 jbc		0x03,0
 inc		0x35
 djz		0x33
 jmp		a1
 mov		a,0x32
 add		0x34,a
 jbc		0x03,0
 inc		0x35
 mov		a,0x34
 mov		0x30,a
 mov		a,0x35
 mov		0x31,a
 ret
;=====================================================
;  In:Freq_Hi,Freq_Lw , Out:ControlByte1,ControlByte2
;=====================================================
ChangeCtrlByte:
	CLR ControlByte1              ;
	MOV A,@0b00011111  
	AND ControlByte2,A            ;Clear ControlByte1,2
	MOV A,0x31
	MOV Freq_Hi,A
	MOV A,0x30
	MOV Freq_Lw,A
	MOV A,Freq_Hi
	AND A,@0b00000111
	MOV TEMP1,A
	SWAP TEMP1
	BC STATUS,C
	RLC TEMP1
	MOV A,TEMP1
	OR ControlByte1,A
	MOV A,Freq_Lw
	AND A,@0b11111000
	MOV TEMP1,A
	BC STATUS,C
	RRC TEMP1
	RRC TEMP1
	RRC TEMP1
	MOV A,TEMP1
	OR ControlByte1,A
	MOV A,Freq_Lw
	AND A,@0b00000111
	MOV TEMP1,A
	SWAP TEMP1
	BC STATUS,C
	RLC TEMP1
	MOV A,TEMP1
	OR ControlByte2,A
	RET

;================================================
;               DELAY SUBROUTINE
; delay = (1.01325ms * A) at 8MHz/2cycles OSCILLATOR
; delay = DELAYTIME*[COUNTER0*(COUNTER1*3+7)+5)+3
; delay
;================================================
Delay_100ms:
   MOV A,@100
   JMP DELAY
Delay_20ms:
   MOV A,@20
   JMP DELAY
Delay_1ms:
   MOV A,@1
   JMP DELAY
delay_5ms:
    MOV A,@5
DELAY:            ;
	MOV     DELAYTIME,A
DELAY0:
	MOV     A,@50        ;@50   ;delay = DELAYTIME*[COUNTER0*(COUNTER1*6+7)+5)+3
	MOV     COUNTER0,A
DELAY1:
	MOV     A,@12       ;@17
	MOV     COUNTER1,A
DELAY2:
    JBS     PORT8,4
	JMP     DELAYBREAK
	DJZ     COUNTER1
	JMP     DELAY2
    JBS     PORT8,4
	JMP     DELAYBREAK
	DJZ     COUNTER0
	JMP     DELAY1
	DJZ     DELAYTIME
	JMP     DELAY0
	RET
DELAYBREAK:
	BC     WORKFLAGS,FGINTON
	RET
;=========================================================
;  Display Subroutine 
;=========================================================
;=========================================================
;--------------------------------------------------
Display_Freq:
	CALL	CLR_LCD
	BS  R9,LCDEN    ; LCD ON 
    ;
    ;;JBS PORT7,7
    ;;JMP $+4          ; IF PORT7.7 IS HIGH, NONE DISPLAY TRADE MARK  
    ;;MOV A,@0x13     ;
	;;MOV RA,A        ;
    ;;BS  RB,2
;	MOV A,@0x04     ;   TRADE MARK ON
;	MOV RB,A
   ;
    NOP
    JBS     PORT5,7           ;TEST POWER STATUS&SHOW MHz
	JMP     $+3
	CALL    PowerDispOff      ; If Power<2.7v Power Bar Shine
	JMP     $+2
	CALL    PowerDispOn
	NOP
    ;
	MOV A,@0x0c
	MOV RA,A
	MOV A,DispFreq_Lw
    AND A,@0b00001111
    CALL TABLE
    MOV TEMP1,A            ;BACK UP A
	AND A,@0B00001111
	MOV RB,A
	MOV A,@0x0d
	MOV RA,A
	MOV A,TEMP1
	AND A,@0B11110000
	MOV TEMP1,A
	SWAPA TEMP1
	JBC DISPFLAGS,M4on
	OR  A,@0x01
	MOV RB,A                   ; DIGITAL 4
	;
	MOV A,@0x0e
	MOV RA,A
	MOV A,DispFreq_Lw
	AND A,@0b11110000
	MOV TEMP1,A
	SWAPA TEMP1
	CALL TABLE
	MOV TEMP1,A
	AND A,@0B00001111
	MOV RB,A
	MOV A,@0x10
	MOV RA,A
	MOV A,TEMP1
	AND A,@0B11110000
	MOV TEMP1,A
	SWAPA TEMP1
	JBC DISPFLAGS,M3on
	OR  A,@0x01
	MOV RB,A                    ;DIGITAL 3
	;
	MOV A,@0x11
	MOV RA,A
	MOV A,DispFreq_Hi
    AND A,@0b00001111
    CALL TABLE
    MOV TEMP1,A
	AND A,@0B00001111
	MOV RB,A
	MOV A,@0x12
	MOV RA,A
	MOV A,TEMP1
	AND A,@0B11110000
	MOV TEMP1,A
	SWAPA TEMP1
	JBC DISPFLAGS,M2on
	OR  A,@0x01
	MOV RB,A                   ; DIGITAL 2
	
    MOV A,@0x13                ; Digital 1
	MOV RA,A
    BC  RB,3                   ; Clear 
    JBC DispFreq_Hi,4
	BS  RB,3                   ;IF FREQ>100MHz,Display 1
	JBC DISPFLAGS,M1on
	BS  RB,0
Display_End:
	;BS RC,CNT1EN               ;lcd on
	MOV DispFreq_Hi,CharityData1
	MOV DispFreq_Lw,CharityData2
	;NOP
	;NOP
	RET
;-----------------------------------------------------
StatusBarOnOff:
    MOV A,@0x13
	MOV RA,A
	MOV A,@0b00000010
	XOR RB,A
	RET
;----------------------------------------------------------
PowerDispOff:
    MOV A,@0x0b
	MOV RA,A
	BC  RB,1
	BS  RB,2
	BS  RB,3
	MOV A,@0b00000001
	XOR RB,A
	RET
PowerDispOn:
    MOV A,@0x0b
	MOV RA,A
	MOV A,@0x0f
	MOV RB,A
	RET
;--------------------------------------------------------
;================================
;*以下是对IIC总线的操作子程序*
;*********启动总线***********************************
;The START condition precedes all commands to the   *
;devices and is defined as a HIGH to LOW transition *
;of SDA when SCL is HIGH.						   *
;scl	____/~~~~\__								*
;sda	__/~~~\____								 *
;****************************************************
IICStart:
	bc	i2port,scl
	bs	i2port,sda
	bs	i2port,scl
	jmp	$+1
	jmp	$+1
	bc	i2port,sda
	jmp	$+1
	jmp	$+1
	bc	i2port,scl
	ret
;*********停止IIC总线********************************
;The STOP condition is defined as a LOW to HIGH     *
;transition of SDA when SCL is HIGH.				*
;scl	____/~~~~								   *
;sda	______/~~								   *	
;****************************************************
IICStop:
	bc	i2port,scl
	bc	i2port,sda
	jmp	$+1
	jmp	$+1
	bs	i2port,scl
	jmp	$+1
	jmp	$+1
	bs	i2port,sda
	ret
;********检查应答位**********************************
;After a successful data transfer, each receiving   *
;device is required to generate an acknowledge.     *
;The Acknowledging device pulls down the SDA line.  *
;****************************************************
IICRecAck:
	ior	i2port
	or	a,@rdcfg
	iow	i2port
	jmp	$+1
	jmp	$+1	

	bs	i2port,scl
	jmp	$+1	
	jmp	$+1
	jbc	i2port,sda
	jmp	$-1
	bc	i2port,scl
	jmp	$+1
	jmp	$+1
	ior	i2port
	and	a,@wrcfg
	iow	i2port
	ret
;************************************
;**********不对IIC总线产生应答*******
;************************************
IICNoAck:
	bc	i2port,scl
	jmp	$+1
	jmp	$+1
	bs	i2port,sda
	jmp	$+1
	jmp	$+1
	bs	i2port,scl
	jmp	$+1
	jmp	$+1
	bc	i2port,scl
	ret
;**********************************
;*********向IIC总线写数据**********
;**********************************
IICSendByte:
	mov	tmp2,a
	mov	a,@8
	mov	tmp1,a
send_b:	
	rlc	tmp2
	jbc	STATUS,C
	jmp	send_1
	bc	i2port,sda
	jmp	s_ret
send_1:
	bs	i2port,sda
	jmp	$+1
	jmp	$+1
s_ret:
	bs	i2port,scl
	jmp	$+1
	jmp	$+1
	bc	i2port,scl
	jmp	$+1
	jmp	$+1
	djz	tmp1
	jmp	send_b
	ret
;*********************************
;****从IIC总线上读数据子程序******
;*********************************
IICReceiveByte:
	mov	a,@8
	mov	tmp1,a
	clr	tmp2
	
	ior	i2port
	or	a,@rdcfg
	iow	i2port
	jmp	$+1
	jmp	$+1
rece_b:
	bs	i2port,scl
	jmp	$+1
	jmp	$+1
	jbc	i2port,sda
	jmp	rece_1
	bc	STATUS,C
	jmp	r_ret
rece_1:
	bs	STATUS,C
	jmp	$+1
	jmp	$+1
r_ret:
	bc	i2port,scl	
	jmp	$+1
	jmp	$+1
	rlc	tmp2	
	djz	tmp1
	jmp	rece_b
	
	ior	i2port
	and	a,@wrcfg
	iow	i2port
	ret
;--------------------------------------------
	ORG	0fffh
	jmp	reset
;--------------------------------------------------------
	END

⌨️ 快捷键说明

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