Sari la conținut
ELFORUM - Forumul electronistilor

Ajutor modificare soft 12F675


florin70il

Postări Recomandate

Va salut stimati colegi. Sunt varza in programare, drept pentru care va cer ajutorul. Am un soft de telecomanda de la userul fratello, codare RC5, 5 butoane. Totul functioneaza cu o singura problema, codurile 16 si 17 sunt transmise doar o data, si ar trebui transmise ciclic,atata timp cat se tine butonul respectiv apasat. Ma poate ajuta cineva? Va multumesc.

;------------------------------------------------------; PROJECT :           5 CHANNEL TX IR REMOTE; without CRYSTAL ; Modify by Niculescu Dan, january 2010; RC5 FORMAT @38KHz , 35% DUTY CYCLE;;           PIC12F675:                    +--U--+                                         ;                                    +5V  [     ]  GND                                    ;                         key 5 |---/--- >[     ]< ---/---| key 1     ;                         key 4 |---/--- >[     ]< ---/---| key 2                   ;       pull-up!          key 3 |---/--- >[     ]>--[4K7]-- NPN Transistor, IR LED                   ;                                         +-----+                          ; WWW.SIXCA.COM;------------------------------------------------------	list P=12F675	#include <P12F675.INC>	__config _WDT_OFF & _INTRC_OSC_NOCLKOUT & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _PWRTE_ON#DEFINE CH1	GPIO,0	        ; CONNECT WITH TX SWITCH CHANNEL 1#DEFINE CH2	GPIO,1	        ; CONNECT WITH TX SWITCH CHANNEL 2#DEFINE CH3	GPIO,3	        ; CONNECT WITH TX SWITCH CHANNEL 3#DEFINE CH4	GPIO,4	        ; CONNECT WITH TX SWITCH CHANNEL 4#DEFINE CH5 GPIO,5          ; CONNECT WITH TX SWITCH CHANNEL 5#DEFINE IR	GPIO,2	        ; CONNECT WITH IR LED WITH TRANSISTOR DRIVES#DEFINE TOG_BIT TOGGLE,0    ; TOGLE BIT NOT USE FOR THIS PROJECT	#DEFINE CH1_CMD	.16  	      ; CHANNEL 1 COMMAND - Vol Up               ; aici se modifica codul tastei, dupa preferinte#DEFINE CH2_CMD	.17	        ; CHANNEL 2 COMMAND - Vol Down#DEFINE CH3_CMD	.32		      ; CHANNEL 3 COMMAND - Source#DEFINE CH4_CMD	.33 	      ; CHANNEL 4 COMMAND - ON/OFF#DEFINE CH5_CMD .13         ; CHANNEL 4 COMMAND - MUTECNT1	EQU	20HCNT2	EQU	21HCNT3	EQU	22HCNT4	EQU	23HTOGGLE	EQU	24HCMD	EQU	25H	          ; IR COMMAND BUFFER	ORG	000	BCF	IR	BSF	STATUS,RP0	CALL	0X3FF	MOVWF	OSCCAL	BCF	STATUS,RP0	CALL	DEBOUNCE	;	MOVLW	0X07	MOVWF	CMCON		      ; MAKE ALL GPIO TO DIGITAL I/O	BSF	STATUS,RP0	BCF	OPTION_REG,7    ; PULLUP SE ACTIVEAZA INDIVIDUAL	MOVLW 	B'00111011'	MOVWF 	WPU			    ; ACTIVARE PULLUP LA TOATE MAI PUTIN .2	MOVLW	B'00111011'	  ; GPIO.01345=IN, GPIO 2 = OUT	MOVWF	TRISIO	clrf	ANSEL				  ; No analog here, we want digital because is 12F675 !	; no need if using 12F629	BCF 	INTCON,GPIF   	BSF	IOC,IOC0	BSF	IOC,IOC1	BSF	IOC,IOC3	BSF	IOC,IOC4	BSF	IOC,IOC5	BSF	INTCON,GPIE	BCF	STATUS,RP0		BCF	INTCON,GIE		BCF	TOG_BIT	BCF	GPIO,5	;------------------------------------; MAIN LOOP	MAIN:	NOP	SLEEP	          ; GOTO SLEEP MODE(I'm a sleepy! and need to save my energy)	NOP	BCF 	INTCON,GPIF	BTFSS	CH1	GOTO	DO_CH1	BTFSS	CH2	GOTO	DO_CH2	BTFSS	CH3	GOTO	DO_CH3	BTFSS	CH4	GOTO	DO_CH4	BTFSS	CH5	GOTO	DO_CH5	GOTO	MAIN	;------------------------------------DO_CH1:	CALL	DEBOUNCE	BTFSC	CH1	GOTO	MAIN	MOVLW	CH1_CMD	  ; LOAD COMMANE FOR CHANNEL 1	MOVWF	CMD	CALL	SEND_RC5	;	BTFSS	CH1	GOTO	$-1	      ; WAIT FOR SWITCH RELEASED	;	CALL	DEBOUNCE	; DELAY AFTER SWITCH RELEASED	GOTO	MAIN;------------------------------------	DO_CH2:	CALL	DEBOUNCE	BTFSC	CH2	GOTO	MAIN	MOVLW	CH2_CMD	  ; LOAD COMMANE FOR CHANNEL 2	MOVWF	CMD	CALL	SEND_RC5	;	BTFSS	CH2	GOTO	$-1	      ; WAIT FOR SWITCH RELEASED	;	CALL	DEBOUNCE	; DELAY AFTER SWITCH RELEASED	GOTO	MAIN	;;------------------------------------	DO_CH3:	CALL	DEBOUNCE	BTFSC	CH3	GOTO	MAIN	MOVLW	CH3_CMD	  ; LOAD COMMANE FOR CHANNEL 3	MOVWF	CMD	CALL	SEND_RC5	;	BTFSS	CH3	GOTO	$-1	      ; WAIT FOR SWITCH RELEASED	;	CALL	DEBOUNCE	; DELAY AFTER SWITCH RELEASED	GOTO	MAIN	;	;------------------------------------	DO_CH4:	CALL	DEBOUNCE	BTFSC	CH4	GOTO	MAIN	MOVLW	CH4_CMD	  ; LOAD COMMANE FOR CHANNEL 4	MOVWF	CMD	CALL	SEND_RC5	;	BTFSS	CH4	GOTO	$-1	      ; WAIT FOR SWITCH RELEASED	;	CALL	DEBOUNCE	; DELAY AFTER SWITCH RELEASED	GOTO	MAIN	;;-------------------------------------DO_CH5:	CALL	DEBOUNCE	BTFSC	CH5	GOTO	MAIN	MOVLW	CH5_CMD	  ; LOAD COMMAND FOR CHANNEL 5	MOVWF	CMD	CALL	SEND_RC5	;	BTFSS	CH5	GOTO	$-1	      ; WAIT FOR SWITCH RELEASED	;	CALL	DEBOUNCE	; DELAY AFTER SWITCH RELEASED	GOTO	MAIN	;======================================; SEND LOGIC 0;======================================LOGIC0:	MOVLW	.35	; 1	MOVWF	CNT1		  ; 1	;LOG0_1:	BSF	IR		; 1 MAKE IR HIGH 35% Duty cycle = 9 uS	GOTO	$+1	GOTO	$+1	GOTO	$+1	GOTO	$+1	;	;===================================	BCF	IR		      ; 1 MAKE IR LOW 17 uS	GOTO	$+1	GOTO	$+1	GOTO	$+1	GOTO	$+1	GOTO	$+1	GOTO	$+1	NOP			        ; 1	;	DECFSZ	CNT1,F	; 1/2	GOTO	LOG0_1		; 2    26 uS	;	CALL	DELAY_OFF	RETURN			    ; 2	;;======================================; SEND LOGIC 1;======================================LOGIC1:	CALL	DELAY_OFF	; DELAY 899 uS	MOVLW	.35		    ; 1	MOVWF	CNT1		  ; 1	;LOG1_1:	BSF	IR		; 1 MAKE IR HIGH 35% Duty cycle = 9 uS	GOTO	$+1	GOTO	$+1	GOTO	$+1	GOTO	$+1	;	;===================================	BCF	IR		      ; 1 MAKE IR LOW 17 uS	GOTO	$+1	GOTO	$+1	GOTO	$+1	GOTO	$+1	GOTO	$+1	GOTO	$+1	NOP			        ; 1	;	DECFSZ	CNT1,F	; 1/2	GOTO	LOG1_1		; 2	;	RETURN			    ; 2	;;======================================; DELAY FOR NO CARRAIR; DELAY ABOUT 835 uS;======================================DELAY_OFF:	MOVLW	5		      ; 1	MOVWF	CNT3		  ; 1		MOVLW	.57		    ; 1		'54	MOVWF	CNT4		  ; 1	DECFSZ	CNT4,F	; 1/2	GOTO	$-1		    ; 2		DECFSZ	CNT3,F  ; 1/2	GOTO	$-5		    ; 2	RETURN			    ; 2	;======================================; SEND RC5 TO REMOTE; INPUT : CMD (6 BIT IR COMMAND);======================================SEND_RC5:	; SEND 2 START  BIT	CALL	LOGIC1	CALL	LOGIC1	; SEND TOGGLE BIT	BTFSS	TOG_BIT	GOTO	$+3	CALL	LOGIC1	GOTO	$+2	CALL	LOGIC0	; SEND ADDRESS 5 BIT FIX AT 01011 (0X0B) IT MAY BE CHANGED BY YOU	CALL	LOGIC0	  ; 0  MSB FIRST BIT 4	CALL	LOGIC0	  ; 1	CALL	LOGIC0	  ; 0	CALL	LOGIC0	  ; 1	CALL	LOGIC0	  ; 1  LSB BIT 0	;	; SEND COMMAND 6 BIT(00HH LLLL) MSB FIRST	BCF	STATUS,C	RLF	CMD,F	      ; AFTER FIRST ROTAGE 0HHL LLL0	RLF	CMD,F	      ; AFTER SECOND ROTAGE HHLL LL00	;	MOVLW	6	MOVWF	CNT2	;	RLF	CMD,F    	  ; SEND MSB FIRST	BTFSS	STATUS,C	GOTO	$+3	CALL	LOGIC1	GOTO	$+2	;	CALL	LOGIC0	DECFSZ	CNT2,F	GOTO	$-7	;	RETLW	0			;		;======================================; DEBOUNCE SWITCH; DELAY 15 mS;======================================DEBOUNCE:	MOVLW	.1		    ; 1	MOVWF	CNT1		  ; 1DEL_1:	MOVLW	.20	MOVWF	CNT2		  ; 1DEL_2:	CLRF	CNT3		; 1DEL_3:	DECFSZ	CNT3,F		; 1/2	GOTO	DEL_3		  ; 2	DECFSZ	CNT2,F	; 1/2	GOTO	DEL_2		  ; 2	DECFSZ	CNT1,F	; 1/2	GOTO	DEL_1		  ; 2	RETLW	0		      ; 2		END				
Link spre comentariu
  • Răspunsuri 5
  • Creat
  • Ultimul Răspuns

Top autori în acest subiect

  • bercioiu

    3

  • florin70il

    3

Top autori în acest subiect

Pai modifici cele 5 sectiuni "DO_CHx" (x = 1 to 5)DO_CH1: CALL DEBOUNCE BTFSC CH1 GOTO MAIN MOVLW CH1_CMD ; LOAD COMMANE FOR CHANNEL 1 MOVWF CMD CALL SEND_RC5 ; BTFSS CH1 GOTO DO_CH1: ; WAIT FOR SWITCH RELEASED (in loc de "$-1" pui "DO_CH1:")sau adaugi o eticheta la "CALL SEND_RC5" si in loc de "$-1" pui eticheta respectiva

Link spre comentariu

Uite, am pus cate un label la fiecare canal "SENDx" . Sper sa mearga, cred ca mai trebuie si cate un delay, nu sunt sigur... Si eu sunt super incepator... Poate ne ajuta un senior...

 

;------------------------------------------------------; PROJECT :           5 CHANNEL TX IR REMOTE; without CRYSTAL; Modify by Niculescu Dan, january 2010; RC5 FORMAT @38KHz , 35% DUTY CYCLE;;           PIC12F675:                    +--U--+                                         ;                                    +5V  [     ]  GND                                   ;                         key 5 |---/--- >[     ]< ---/---| key 1     ;                         key 4 |---/--- >[     ]< ---/---| key 2                   ;       pull-up!          key 3 |---/--- >[     ]>--[4K7]-- NPN Transistor, IR LED                   ;                                         +-----+                         ; WWW.SIXCA.COM;------------------------------------------------------   list P=12F675   #include <P12F675.INC>   __config _WDT_OFF & _INTRC_OSC_NOCLKOUT & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _PWRTE_ON#DEFINE CH1   GPIO,0           ; CONNECT WITH TX SWITCH CHANNEL 1#DEFINE CH2   GPIO,1           ; CONNECT WITH TX SWITCH CHANNEL 2#DEFINE CH3   GPIO,3           ; CONNECT WITH TX SWITCH CHANNEL 3#DEFINE CH4   GPIO,4           ; CONNECT WITH TX SWITCH CHANNEL 4#DEFINE CH5 GPIO,5          ; CONNECT WITH TX SWITCH CHANNEL 5#DEFINE IR   GPIO,2           ; CONNECT WITH IR LED WITH TRANSISTOR DRIVES#DEFINE TOG_BIT TOGGLE,0    ; TOGLE BIT NOT USE FOR THIS PROJECT   #DEFINE CH1_CMD   .16           ; CHANNEL 1 COMMAND - Vol Up               ; aici se modifica codul tastei, dupa preferinte#DEFINE CH2_CMD   .17           ; CHANNEL 2 COMMAND - Vol Down#DEFINE CH3_CMD   .32            ; CHANNEL 3 COMMAND - Source#DEFINE CH4_CMD   .33          ; CHANNEL 4 COMMAND - ON/OFF#DEFINE CH5_CMD .13         ; CHANNEL 4 COMMAND - MUTECNT1   EQU   20HCNT2   EQU   21HCNT3   EQU   22HCNT4   EQU   23HTOGGLE   EQU   24HCMD   EQU   25H             ; IR COMMAND BUFFER   ORG   000   BCF   IR   BSF   STATUS,RP0   CALL   0X3FF   MOVWF   OSCCAL   BCF   STATUS,RP0   CALL   DEBOUNCE   ;   MOVLW   0X07   MOVWF   CMCON            ; MAKE ALL GPIO TO DIGITAL I/O   BSF   STATUS,RP0   BCF   OPTION_REG,7    ; PULLUP SE ACTIVEAZA INDIVIDUAL   MOVLW    B'00111011'   MOVWF    WPU             ; ACTIVARE PULLUP LA TOATE MAI PUTIN .2   MOVLW   B'00111011'     ; GPIO.01345=IN, GPIO 2 = OUT   MOVWF   TRISIO   clrf   ANSEL              ; No analog here, we want digital because is 12F675 !   ; no need if using 12F629   BCF    INTCON,GPIF      BSF   IOC,IOC0   BSF   IOC,IOC1   BSF   IOC,IOC3   BSF   IOC,IOC4   BSF   IOC,IOC5   BSF   INTCON,GPIE   BCF   STATUS,RP0      BCF   INTCON,GIE      BCF   TOG_BIT   BCF   GPIO,5   ;------------------------------------; MAIN LOOP   MAIN:   NOP   SLEEP             ; GOTO SLEEP MODE(I'm a sleepy! and need to save my energy)   NOP   BCF    INTCON,GPIF   BTFSS   CH1   GOTO   DO_CH1   BTFSS   CH2   GOTO   DO_CH2   BTFSS   CH3   GOTO   DO_CH3   BTFSS   CH4   GOTO   DO_CH4   BTFSS   CH5   GOTO   DO_CH5   GOTO   MAIN   ;------------------------------------DO_CH1:   CALL   DEBOUNCE   BTFSC   CH1   GOTO   MAIN   MOVLW   CH1_CMD     ; LOAD COMMANE FOR CHANNEL 1   MOVWF   CMDSEND1   CALL   SEND_RC5   ;   BTFSS   CH1   ; GOTO   $-1         ; WAIT FOR SWITCH RELEASED   GOTO   SEND1   ;   CALL   DEBOUNCE   ; DELAY AFTER SWITCH RELEASED   GOTO   MAIN;------------------------------------   DO_CH2:   CALL   DEBOUNCE   BTFSC   CH2   GOTO   MAIN   MOVLW   CH2_CMD     ; LOAD COMMANE FOR CHANNEL 2   MOVWF   CMDSEND2   CALL   SEND_RC5   ;   BTFSS   CH2   ;GOTO   $-1         ; WAIT FOR SWITCH RELEASED   GOTO   SEND2   ;   CALL   DEBOUNCE   ; DELAY AFTER SWITCH RELEASED   GOTO   MAIN   ;;------------------------------------   DO_CH3:   CALL   DEBOUNCE   BTFSC   CH3   GOTO   MAIN   MOVLW   CH3_CMD     ; LOAD COMMANE FOR CHANNEL 3   MOVWF   CMDSEND3   CALL   SEND_RC5   ;   BTFSS   CH3   ;GOTO   $-1         ; WAIT FOR SWITCH RELEASED   GOTO   SEND3   ;   CALL   DEBOUNCE   ; DELAY AFTER SWITCH RELEASED   GOTO   MAIN   ;   ;------------------------------------   DO_CH4:   CALL   DEBOUNCE   BTFSC   CH4   GOTO   MAIN   MOVLW   CH4_CMD     ; LOAD COMMANE FOR CHANNEL 4   MOVWF   CMDSEND4   CALL   SEND_RC5   ;   BTFSS   CH4   ;GOTO   $-1         ; WAIT FOR SWITCH RELEASED   GOTO   SEND4   ;   CALL   DEBOUNCE   ; DELAY AFTER SWITCH RELEASED   GOTO   MAIN   ;;-------------------------------------DO_CH5:   CALL   DEBOUNCE   BTFSC   CH5   GOTO   MAIN   MOVLW   CH5_CMD     ; LOAD COMMAND FOR CHANNEL 5   MOVWF   CMDSEND5   CALL   SEND_RC5   ;   BTFSS   CH5   ;GOTO   $-1         ; WAIT FOR SWITCH RELEASED   GOTO   SEND5   ;   CALL   DEBOUNCE   ; DELAY AFTER SWITCH RELEASED   GOTO   MAIN   ;======================================; SEND LOGIC 0;======================================LOGIC0:   MOVLW   .35   ; 1   MOVWF   CNT1        ; 1   ;LOG0_1:   BSF   IR      ; 1 MAKE IR HIGH 35% Duty cycle = 9 uS   GOTO   $+1   GOTO   $+1   GOTO   $+1   GOTO   $+1   ;   ;===================================   BCF   IR            ; 1 MAKE IR LOW 17 uS   GOTO   $+1   GOTO   $+1   GOTO   $+1   GOTO   $+1   GOTO   $+1   GOTO   $+1   NOP                 ; 1   ;   DECFSZ   CNT1,F   ; 1/2   GOTO   LOG0_1      ; 2    26 uS   ;   CALL   DELAY_OFF   RETURN             ; 2   ;;======================================; SEND LOGIC 1;======================================LOGIC1:   CALL   DELAY_OFF   ; DELAY 899 uS   MOVLW   .35          ; 1   MOVWF   CNT1        ; 1   ;LOG1_1:   BSF   IR      ; 1 MAKE IR HIGH 35% Duty cycle = 9 uS   GOTO   $+1   GOTO   $+1   GOTO   $+1   GOTO   $+1   ;   ;===================================   BCF   IR            ; 1 MAKE IR LOW 17 uS   GOTO   $+1   GOTO   $+1   GOTO   $+1   GOTO   $+1   GOTO   $+1   GOTO   $+1   NOP                 ; 1   ;   DECFSZ   CNT1,F   ; 1/2   GOTO   LOG1_1      ; 2   ;   RETURN             ; 2   ;;======================================; DELAY FOR NO CARRAIR; DELAY ABOUT 835 uS;======================================DELAY_OFF:   MOVLW   5            ; 1   MOVWF   CNT3        ; 1      MOVLW   .57          ; 1      '54   MOVWF   CNT4        ; 1   DECFSZ   CNT4,F   ; 1/2   GOTO   $-1          ; 2      DECFSZ   CNT3,F  ; 1/2   GOTO   $-5          ; 2   RETURN             ; 2   ;======================================; SEND RC5 TO REMOTE; INPUT : CMD (6 BIT IR COMMAND);======================================SEND_RC5:   ; SEND 2 START  BIT   CALL   LOGIC1   CALL   LOGIC1   ; SEND TOGGLE BIT   BTFSS   TOG_BIT   GOTO   $+3   CALL   LOGIC1   GOTO   $+2   CALL   LOGIC0   ; SEND ADDRESS 5 BIT FIX AT 01011 (0X0B) IT MAY BE CHANGED BY YOU   CALL   LOGIC0     ; 0  MSB FIRST BIT 4   CALL   LOGIC0     ; 1   CALL   LOGIC0     ; 0   CALL   LOGIC0     ; 1   CALL   LOGIC0     ; 1  LSB BIT 0   ;   ; SEND COMMAND 6 BIT(00HH LLLL) MSB FIRST   BCF   STATUS,C   RLF   CMD,F         ; AFTER FIRST ROTAGE 0HHL LLL0   RLF   CMD,F         ; AFTER SECOND ROTAGE HHLL LL00   ;   MOVLW   6   MOVWF   CNT2   ;   RLF   CMD,F         ; SEND MSB FIRST   BTFSS   STATUS,C   GOTO   $+3   CALL   LOGIC1   GOTO   $+2   ;   CALL   LOGIC0   DECFSZ   CNT2,F   GOTO   $-7   ;   RETLW   0         ;      ;======================================; DEBOUNCE SWITCH; DELAY 15 mS;======================================DEBOUNCE:   MOVLW   .1          ; 1   MOVWF   CNT1        ; 1DEL_1:   MOVLW   .20   MOVWF   CNT2        ; 1DEL_2:   CLRF   CNT3      ; 1DEL_3:   DECFSZ   CNT3,F      ; 1/2   GOTO   DEL_3        ; 2   DECFSZ   CNT2,F   ; 1/2   GOTO   DEL_2        ; 2   DECFSZ   CNT1,F   ; 1/2   GOTO   DEL_1        ; 2   RETLW   0            ; 2      END
Link spre comentariu

Multumesc foarte mult pentru ajutor, a mers prima varianta, cea cu GOTO DO_CHx, pe a doua nu am mai incercat-o. Acum transmite ciclic pe key 1 si key 2(Vol+ si Vol-). Pentru cei doritori, afisez codul asm. Schema este in headerul asm.

;------------------------------------------------------

; PROJECT : 5 CHANNEL TX IR REMOTE

; without CRYSTAL

; Modify by Niculescu Dan, january 2010

; RC5 FORMAT @38KHz , 35% DUTY CYCLE

;

; PIC12F629: +--U--+

; +5V [ ] GND

; key 5 |---/--- >[ ]< ---/---| key 1

; key 4 |---/--- >[ ]< ---/---| key 2

; pull-up 10k! key 3 |---/--- >[ ]>--[4K7]-- NPN Transistor, IR LED

; +-----+

; WWW.SIXCA.COM

;------------------------------------------------------

 

list P=12F629

#include

__config _WDT_OFF & _INTRC_OSC_NOCLKOUT & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _PWRTE_ON

 

 

#DEFINE CH1 GPIO,0 ; CONNECT WITH TX SWITCH CHANNEL 1

#DEFINE CH2 GPIO,1 ; CONNECT WITH TX SWITCH CHANNEL 2

#DEFINE CH3 GPIO,3 ; CONNECT WITH TX SWITCH CHANNEL 3

#DEFINE CH4 GPIO,4 ; CONNECT WITH TX SWITCH CHANNEL 4

#DEFINE CH5 GPIO,5 ; CONNECT WITH TX SWITCH CHANNEL 5

 

#DEFINE IR GPIO,2 ; CONNECT WITH IR LED WITH TRANSISTOR DRIVES

 

#DEFINE TOG_BIT TOGGLE,0 ; TOGLE BIT NOT USE FOR THIS PROJECT

 

#DEFINE CH1_CMD .16 ; CHANNEL 1 COMMAND - Vol Up ; aici se modifica codul tastei, dupa preferinte

#DEFINE CH2_CMD .17 ; CHANNEL 2 COMMAND - Vol Down

#DEFINE CH3_CMD .32 ; CHANNEL 3 COMMAND - CH+

#DEFINE CH4_CMD .33 ; CHANNEL 4 COMMAND - CH-

#DEFINE CH5_CMD .13 ; CHANNEL 4 COMMAND - MUTE

 

CNT1 EQU 20H

CNT2 EQU 21H

CNT3 EQU 22H

CNT4 EQU 23H

TOGGLE EQU 24H

CMD EQU 25H ; IR COMMAND BUFFER

 

ORG 000

BCF IR

BSF STATUS,RP0

CALL 0X3FF

MOVWF OSCCAL

BCF STATUS,RP0

CALL DEBOUNCE

;

MOVLW 0X07

MOVWF CMCON ; MAKE ALL GPIO TO DIGITAL I/O

BSF STATUS,RP0

BCF OPTION_REG,7 ; PULLUP SE ACTIVEAZA INDIVIDUAL

MOVLW B'00111011'

MOVWF WPU ; ACTIVARE PULLUP LA TOATE MAI PUTIN .2

MOVLW B'00111011' ; GPIO.01345=IN, GPIO 2 = OUT

MOVWF TRISIO

;clrf ANSEL ;setari pentru 12F629, "clrf ANSEL" este pentru 12F675

; no need if using 12F629

BCF INTCON,GPIF

BSF IOC,IOC0

BSF IOC,IOC1

BSF IOC,IOC3

BSF IOC,IOC4

BSF IOC,IOC5

BSF INTCON,GPIE

BCF STATUS,RP0

BCF INTCON,GIE

BCF TOG_BIT

BCF GPIO,5

 

;------------------------------------

; MAIN LOOP

MAIN:

NOP

SLEEP ; GOTO SLEEP MODE(I'm a sleepy! and need to save my energy)

NOP

BCF INTCON,GPIF

BTFSS CH1

GOTO DO_CH1

BTFSS CH2

GOTO DO_CH2

BTFSS CH3

GOTO DO_CH3

BTFSS CH4

GOTO DO_CH4

BTFSS CH5

GOTO DO_CH5

 

GOTO MAIN

 

;------------------------------------

DO_CH1: CALL DEBOUNCE

BTFSC CH1

GOTO MAIN

MOVLW CH1_CMD ; LOAD COMMANE FOR CHANNEL 1

MOVWF CMD

CALL SEND_RC5

;

BTFSS CH1

GOTO DO_CH1 ; WAIT FOR SWITCH RELEASED

;

CALL DEBOUNCE ; DELAY AFTER SWITCH RELEASED

GOTO MAIN

 

;------------------------------------

DO_CH2: CALL DEBOUNCE

BTFSC CH2

GOTO MAIN

MOVLW CH2_CMD ; LOAD COMMANE FOR CHANNEL 2

MOVWF CMD

CALL SEND_RC5

;

BTFSS CH2

GOTO DO_CH2 ; WAIT FOR SWITCH RELEASED

;

CALL DEBOUNCE ; DELAY AFTER SWITCH RELEASED

GOTO MAIN

;

;------------------------------------

DO_CH3: CALL DEBOUNCE

BTFSC CH3

GOTO MAIN

MOVLW CH3_CMD ; LOAD COMMANE FOR CHANNEL 3

MOVWF CMD

CALL SEND_RC5

;

BTFSS CH3

GOTO $-1 ; WAIT FOR SWITCH RELEASED

;

CALL DEBOUNCE ; DELAY AFTER SWITCH RELEASED

GOTO MAIN

;

;------------------------------------

DO_CH4: CALL DEBOUNCE

BTFSC CH4

GOTO MAIN

MOVLW CH4_CMD ; LOAD COMMANE FOR CHANNEL 4

MOVWF CMD

CALL SEND_RC5

;

BTFSS CH4

GOTO $-1 ; WAIT FOR SWITCH RELEASED

;

CALL DEBOUNCE ; DELAY AFTER SWITCH RELEASED

GOTO MAIN

;

;-------------------------------------

DO_CH5: CALL DEBOUNCE

BTFSC CH5

GOTO MAIN

MOVLW CH5_CMD ; LOAD COMMAND FOR CHANNEL 5

MOVWF CMD

CALL SEND_RC5

;

BTFSS CH5

GOTO $-1 ; WAIT FOR SWITCH RELEASED

;

CALL DEBOUNCE ; DELAY AFTER SWITCH RELEASED

GOTO MAIN

 

;======================================

; SEND LOGIC 0

;======================================

LOGIC0: MOVLW .35 ; 1

MOVWF CNT1 ; 1

;

LOG0_1: BSF IR ; 1 MAKE IR HIGH 35% Duty cycle = 9 uS

GOTO $+1

GOTO $+1

GOTO $+1

GOTO $+1

;

;===================================

BCF IR ; 1 MAKE IR LOW 17 uS

GOTO $+1

GOTO $+1

GOTO $+1

GOTO $+1

GOTO $+1

GOTO $+1

NOP ; 1

;

DECFSZ CNT1,F ; 1/2

GOTO LOG0_1 ; 2 26 uS

;

CALL DELAY_OFF

RETURN ; 2

;

;======================================

; SEND LOGIC 1

;======================================

LOGIC1: CALL DELAY_OFF ; DELAY 899 uS

MOVLW .35 ; 1

MOVWF CNT1 ; 1

;

LOG1_1: BSF IR ; 1 MAKE IR HIGH 35% Duty cycle = 9 uS

GOTO $+1

GOTO $+1

GOTO $+1

GOTO $+1

;

;===================================

BCF IR ; 1 MAKE IR LOW 17 uS

GOTO $+1

GOTO $+1

GOTO $+1

GOTO $+1

GOTO $+1

GOTO $+1

NOP ; 1

;

DECFSZ CNT1,F ; 1/2

GOTO LOG1_1 ; 2

;

RETURN ; 2

;

;======================================

; DELAY FOR NO CARRAIR

; DELAY ABOUT 835 uS

;======================================

DELAY_OFF:

MOVLW 5 ; 1

MOVWF CNT3 ; 1

MOVLW .57 ; 1 '54

MOVWF CNT4 ; 1

DECFSZ CNT4,F ; 1/2

GOTO $-1 ; 2

DECFSZ CNT3,F ; 1/2

GOTO $-5 ; 2

RETURN ; 2

 

;======================================

; SEND RC5 TO REMOTE

; INPUT : CMD (6 BIT IR COMMAND)

;======================================

SEND_RC5:

; SEND 2 START BIT

CALL LOGIC1

CALL LOGIC1

; SEND TOGGLE BIT

BTFSS TOG_BIT

GOTO $+3

CALL LOGIC1

GOTO $+2

CALL LOGIC0

 

; SEND ADDRESS 5 BIT FIX AT 01011 (0X0B) IT MAY BE CHANGED BY YOU

CALL LOGIC0 ; 0 MSB FIRST BIT 4

CALL LOGIC0 ; 1

CALL LOGIC0 ; 0

CALL LOGIC0 ; 1

CALL LOGIC0 ; 1 LSB BIT 0

;

; SEND COMMAND 6 BIT(00HH LLLL) MSB FIRST

BCF STATUS,C

RLF CMD,F ; AFTER FIRST ROTAGE 0HHL LLL0

RLF CMD,F ; AFTER SECOND ROTAGE HHLL LL00

;

MOVLW 6

MOVWF CNT2

;

RLF CMD,F ; SEND MSB FIRST

BTFSS STATUS,C

GOTO $+3

CALL LOGIC1

GOTO $+2

;

CALL LOGIC0

DECFSZ CNT2,F

GOTO $-7

;

RETLW 0

;

 

;======================================

; DEBOUNCE SWITCH

; DELAY 15 mS

;======================================

DEBOUNCE:

MOVLW .1 ; 1

MOVWF CNT1 ; 1

DEL_1: MOVLW .20

MOVWF CNT2 ; 1

DEL_2: CLRF CNT3 ; 1

DEL_3: DECFSZ CNT3,F ; 1/2

GOTO DEL_3 ; 2

DECFSZ CNT2,F ; 1/2

GOTO DEL_2 ; 2

DECFSZ CNT1,F ; 1/2

GOTO DEL_1 ; 2

RETLW 0 ; 2

 

END

Link spre comentariu

Creează un cont sau autentifică-te pentru a adăuga comentariu

Trebuie să fi un membru pentru a putea lăsa un comentariu.

Creează un cont

Înregistrează-te pentru un nou cont în comunitatea nostră. Este simplu!

Înregistrează un nou cont

Autentificare

Ai deja un cont? Autentifică-te aici.

Autentifică-te acum



×
×
  • Creează nouă...

Informații Importante

Am plasat cookie-uri pe dispozitivul tău pentru a îmbunătății navigarea pe acest site. Poți modifica setările cookie, altfel considerăm că ești de acord să continui.Termeni de Utilizare si Ghidări