專注差異化嵌入式產(chǎn)品解決方案 給智能產(chǎn)品定制注入靈魂給予生命
提供開發(fā)工具、應(yīng)用測(cè)試 完善的開發(fā)代碼案例庫(kù)分享
從全面的產(chǎn)品導(dǎo)入到強(qiáng)大技術(shù)支援服務(wù) 全程貼心伴隨服務(wù),創(chuàng)造無(wú)限潛能!
提供新的芯片及解決方案,提升客戶產(chǎn)品競(jìng)爭(zhēng)力
提供最新的單片機(jī)資訊,行業(yè)消息以及公司新聞動(dòng)態(tài)
include
COUNT EQU 20H
COUNT1 EQU 21H
COUNT2 EQU 22H
ADDRES EQU 23H
SENDBUF EQU 24H ;存鍵值
TXBUF EQU 25H
MM EQU 26H ;10MS DELAY
NN EQU 27H
AA EQU 28H ; DELAY1
BB EQU 29H
TVDATA EQU 2AH
;=============================
ORG 10H
START
BSF STATUS,RP0
MOVLW B’11111111’ ;RA4頻道下翻
MOVWF TRISA
MOVLW B’00000001’
MOVWF TRISB ;RB0頻道上翻 RB1 LED
MOVLW B’11111110’
MOVWF TRISC ;RC0 紅外輸出
BCF STATUS,RP0
BCF PORTC,0 ;紅外輸出口
BSF PORTB,1 ;復(fù)位時(shí)RB1 LED閃二下,表示工作正常。
CALL DELAY1
BCF PORTB,1
CALL DELAY1
BSF PORTB,1
CALL DELAY1
BCF PORTB,1
CALL DELAY1
;================鍵掃描=================
MAIN
BTFSS PORTB,0 ;RB0頻道上翻
GOTO SCHUP ;PORTB常態(tài)是高電平,低電平有鍵按下。
BTFSS PORTA,4 ;RA4頻道下翻
GOTO SCHDOWN
GOTO MAIN
;==========頻道上翻=============
SCHUP CALL DELAY ;鍵去抖
BTFSC PORTB,0
GOTO MAIN
BTFSS PORTB,0 ;鍵釋放?
GOTO $-1
BSF PORTB,1
;
MOVLW B’00110100’ ;TV ADRESS(寫入自己的彩電地址碼)
MOVWF ADDRES
MOVLW B’00000001’ ;TV DATA
MOVWF TVDATA
CALL SEND ;發(fā)送一次紅外信號(hào)
MOVLW B’00110100’ ;TV ADRESS
MOVWF ADDRES
MOVLW B’00000001’ ;TV DATA
MOVWF TVDATA
CALL SEND ;發(fā)送一次紅外信號(hào)
GOTO MAIN
;==========頻道下翻=============
SCHDOWN CALL DELAY ;鍵去抖
BTFSC PORTA,4
GOTO MAIN
BTFSS PORTA,4 ;鍵釋放?
GOTO $-1
BSF PORTA,4
;
MOVLW B’00110100’ ;TV ADRESS
MOVWF ADDRES
MOVLW B’00000010’ ;TV DATA
MOVWF TVDATA
CALL SEND ;發(fā)送一次紅外信號(hào)
MOVLW B’00110100’ ;TV ADRESS
MOVWF ADDRES
MOVLW B’00000010’ ;TV DATA
MOVWF TVDATA
CALL SEND ;發(fā)送一次紅外信號(hào)
GOTO MAIN
;=======發(fā)送8.07mS+4.0MS組成的頭碼=========== (一般是9MS+4.5MS)
SEND MOVLW 0XFF
CALL POUSE
MOVLW 0X34
CALL POUSE
;4.0MS
MOVLW 0XC8
CALL DELAY2
;=========發(fā)送地址===========
MOVF ADDRES,0
CALL TVADDRESS
;========中間插一斷560uS+4MS低===============
MOVLW 0X14
CALL POUSE
MOVLW 0XC8
CALL DELAY2
;=========發(fā)送數(shù)據(jù)===========
MOVF TVDATA,0
CALL TVADDRESS
;===結(jié)尾560US POUSE+22.7MS低電平======
MOVLW 0X13
CALL POUSE
BCF PORTC,0
CALL DELAY ;3MS
CALL DELAY ;3MS
CALL DELAY ;3MS
CALL DELAY ;3MS
CALL DELAY ;3MS
CALL DELAY ;3MS
CALL DELAY ;3MS
RETURN
;===========560uS 高38K頻===============
POUSE MOVWF COUNT ;560uS=0X14
K38 BSF PORTC,0 ;(0XFF+ 0X34)*26.9=8.07mS
NOP ;(0XFF+ 0X4E)*26.9=9mS
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BCF PORTC,0
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
DECFSZ COUNT,1
GOTO K38
RETURN
;===============發(fā)送TV地址和數(shù)據(jù)碼==================
TVADDRESS MOVWF TXBUF ;注意PC示波器先收到的是低位?。?!
MOVLW 0X08
MOVWF COUNT1
TLP BTFSC TXBUF,0 ;地址碼為0就發(fā)0,為1就發(fā)1。
GOTO IDONE
;==========TV 發(fā)送0子程序============
MOVLW 0X14
MOVWF COUNT ; 560uS
TVZERO BSF PORTC,0
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BCF PORTC,0
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
DECFSZ COUNT,1
GOTO TVZERO
;
BCF PORTC,0
MOVLW 0X7D
MOVWF COUNT2 ;480uS
L0TLP NOP
DECFSZ COUNT2,1
GOTO L0TLP
;---------------
GOTO GUR
IDONE
;==========TV 發(fā)送1子程序============
;560uS+1.43mS
MOVLW 0X14
MOVWF COUNT ;560uS
TVONE BSF PORTC,0 ;紅外輸出口
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
BCF PORTC,0
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
DECFSZ COUNT,1
GOTO TVONE
;-------
BCF PORTC,0
MOVLW 0X7D
MOVWF COUNT2 ;1.48mS
L1TLP NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
DECFSZ COUNT2,1
GOTO L1TLP
NOP
NOP
NOP
NOP
NOP
NOP
;-----------------
GUR RRF TXBUF,1
DECFSZ COUNT1,1 ;共8次。
GOTO TLP
RETURN
;
;=========== 3ms鍵去抖 =============
DELAY MOVLW 0X04
MOVWF MM
DY1 MOVLW 0XFF
MOVWF NN
DY2 DECFSZ NN
GOTO DY2
DECFSZ MM
GOTO DY1
RETURN
;=========== LED閃延時(shí) =============
DELAY1 MOVLW 0XFF
MOVWF AA
DYA1 MOVLW 0XFF
MOVWF BB
DYA2 DECFSZ BB
GOTO DYA2
DECFSZ AA
GOTO DYA1
RETURN
;============ 20us*X ================
DELAY2 MOVWF COUNT2 ;0XC8=20us*200=4.0ms
TOPL NOP ;0XE1=20us*225=4.5ms
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
DECFSZ COUNT2,1
GOTO TOPL
RETURN
;=============================
END