;Copyright 1999, 2000, 2001, 2002, 2003 Danijel Pticar Mauri, all rights reserved. ; MODIFICATION OF THIS CODE OR COMERCIAL USE NOT ALOWED WITHOUT CONTACTING AUTHOR FIRST ! ; WWW : http://free-zg.hinet.hr/DPM ; E-mail: danijel.pticar@zg.hinet.hr ; TESTED ON ; Akai, Broksoni (2 types), Canon, Denon, Emerson, Funai, Goldstar, Hitachi (2 types), Jvc (2 types), Kathrein, Kenwood, Mark, Mitshubisi, Nec ; Panasonic (4 types), Onkyo (4 types), Orion, Philips, Pioneer (2 types), Samsung, Sanyo, Schneider, Sharp (2 types), Sony (8 types), Teac, ; Technics, Yamaha, Pioneer Car Audio, RC-37. ; ; Philips & Samsung are RC5 ; ; NOT WORKING : Luxor (carrier frq too high), Salore , Saba ; ; ;!!! Some remotes sends precode+code+postcode . For that kinda remotes first use RCV app (deug mode) to see how signal looks like. ;!!! Some remotes send code + (code xor ???). ; ; ; ComSetup : 9600,8,1 / Hardware Handshaking : None / SoftwareHandshaking : None ; ; ; Danijel Pticar Mauri ; WWW : http://free-zg.hinet.hr/DPM ; E-mail: danijel.pticar@zg.hinet.hr ; !!!!!!! FOR 4MHZ ONLY !!!!!!!! ; ; ; ; ; IR - UIR ; IG - GRAB MODE ; IT - TRANSMIT MODE ; IV - VERSION ON RS232 ; IC - LOAD NEW CONFIG ; ID - DEBUG MODE TITLE "UIRT flash by Danijel Pticar ver 1.22" LIST P=16F84 #include p16F84.inc ;---------------------------------------------------------------------------- __CONFIG _CP_OFF & _PWRTE_OFF & _WDT_OFF & _XT_OSC ;-------------------used in UIR MODE-------------- ;AHHH EQU 020H PULS1 EQU 020H SPACE1 EQU 021H BITMASK EQU 038H ; ****** 038H OUTBYTE1 EQU 023H OUTBYTE2 EQU 024H OUTBYTE3 EQU 025H OUTBYTE4 EQU 026H OUTBYTE5 EQU 027H OUTBYTE6 EQU 028H CODE_TYPE EQU 029H SKIPER EQU 045H ;------------------------------------------------- ;------------------used in (UIRT-MODE)----------------- H_PULS EQU 00CH H_SPACE EQU 00DH PULS_MIN EQU 00EH PULS_MAX EQU 00FH SPACE_MIN EQU 010H SPACE_MAX EQU 011H TEMP1 EQU 012H TEMP2 EQU 013H LENGTH EQU 014H TEMP4 EQU 015H FRQ_DLY EQU 016H TEMP5 EQU 017H B1 EQU 020H B2 EQU 021H B3 EQU 022H B4 EQU 023H B5 EQU 024H B6 EQU 025H B7 EQU 026H B8 EQU 027H B9 EQU 028H B10 EQU 029H B11 EQU 02AH B12 EQU 02BH B13 EQU 02CH B14 EQU 02DH B15 EQU 02EH B16 EQU 02FH ;----------------------CONFIGURATION------------------------------- EE_CFG EQU 020H EE_MASK EQU 021H ;----------------------------------------------------- PULS_0 EQU 032H PULS_1 EQU 037H SPACE_0 EQU 034H SPACE_1 EQU 035H GTEMP1 EQU 036H ;--------------------GENERAL STUFF - MODE EQU 040H ; USED FOR FLAGS TO SEE IN WICH MODE WE ARE (UIR,UIRT-R,UIRT-S) BYTE EQU 042H BITCOUNT EQU 043H DELAY EQU 044H ;--------------------input, output rs232 pins #define TX_PIN PORTB,07 #define RX_PIN PORTB,06 ORG 0000H GOTO INIT ORG 0x004 GOTO SEND_CODE INIT: ;--------------------------- BSF STATUS,RP0 MOVLW B'11111111' MOVWF TRISA MOVLW B'01001000' MOVWF TRISB MOVLW b'11010101' MOVWF OPTION_REG BCF STATUS,RP0 ;--------------------------- CLRF PORTA CLRF PORTB CLRF MODE ;CALL P40KHZ IR_LOOP: CALL RX96 XORLW 'I' BTFSS STATUS,Z GOTO IR_LOOP CALL RX96 XORLW 'R' BTFSC STATUS,Z GOTO UIR_MODE XORLW 'R'^'G' BTFSC STATUS,Z GOTO GRAB_MODE XORLW 'T'^'G' BTFSC STATUS,Z GOTO TRANSMIT_MODE XORLW 'V'^'T' BTFSC STATUS,Z GOTO SHOW_VER XORLW 'C'^'V' BTFSC STATUS,Z GOTO LOAD_CFG XORLW 'S'^'C' BTFSC STATUS,Z GOTO SEND_CFG XORLW 'D'^'S' BTFSC STATUS,Z GOTO DEBUG_REM GOTO IR_LOOP UIR_MODE: MOVLW 'O' CALL TX96 MOVLW 'K' CALL TX96 BSF MODE,00 GOTO UIR_PROGRAM_START SEND_CODE: BTFSC MODE,07 GOTO DEBUG_SEND BTFSC MODE,00 GOTO UIR_SEND BTFSC MODE,01 GOTO GRAB_SEND UIR_SEND: MOVF LENGTH,W ANDLW B'1111100' BTFSC STATUS,Z GOTO UIR_PROGRAM_START ; IR CODE IS TOO SHORT ? MOVLW 038H MOVWF EEADR BSF STATUS,RP0 ; SWITCH BANKS BSF EECON1,RD ; READ EE->EEDATA BCF STATUS,RP0 ; BACK TO NORMAL MOVF EEDATA,W ; ANDLW B'11111011' BTFSS STATUS,Z GOTO NOT_MASK MOVLW 039H MOVWF EEADR BSF STATUS,RP0 ; SWITCH BANKS BSF EECON1,RD ; READ EE->EEDATA BCF STATUS,RP0 ; BACK TO NORMAL MOVF EEDATA,W ; ANDWF OUTBYTE1,F GOTO SEND_OUT NOT_MASK: MOVF EEDATA,W ; ANDLW B'11111101' BTFSS STATUS,Z GOTO SEND_OUT MOVF OUTBYTE1,W ; check isit RC5 XORLW 0CAH BTFSS STATUS,Z GOTO RC5_CHECK2 BCF OUTBYTE1,01 BSF OUTBYTE1,05 RC5_CHECK2: MOVLW .1 ADDWF CODE_TYPE,F ; SPACE=3, PULS=2, RC5=4 BTFSS CODE_TYPE,02 GOTO NOT_RC5 BCF OUTBYTE1,01 BSF OUTBYTE1,05 SEND_OUT: NOT_RC5: MOVF OUTBYTE1,W ; OUTPUT CALL TX96 MOVF OUTBYTE2,W CALL TX96 MOVF OUTBYTE3,W CALL TX96 MOVF OUTBYTE4,W CALL TX96 MOVF OUTBYTE5,W CALL TX96 MOVF OUTBYTE6,W CALL TX96 UIR_PROGRAM_START: CLRF TMR0 BCF INTCON,T0IF ; CLEAR TMR0 INTERUPT MOVLW b'10100000' MOVWF INTCON ; SETUP INTERUPT ON TMR0 MOVLW 00C MOVWF FSR CLRF INDF INCF FSR,F BTFSS FSR,6 GOTO $-3 MOVLW B'10000000' ; BITMASK MOVWF BITMASK CLRF SKIPER INCF SKIPER,F MOVLW 038H CALL EE_READ ANDLW B'11110111' BTFSS STATUS,Z GOTO WAIT_1 MOVLW 039H CALL EE_READ MOVWF SKIPER INCF SKIPER,F ;---------------------main here WAIT_1: CLRF TMR0 ; WAIT FOR PULS TO ARIVE BTFSC PORTB,03 GOTO WAIT_1 CLRF TMR0 ; PULS ARIVED CLEAR TIMER AND STAR COUNTING MOVLW OUTBYTE1 MOVWF FSR WAIT_0A: BTFSS PORTB,03 ; WAIT TO PULS GO DOWN (IR PULS) GOTO WAIT_0A MOVF TMR0,W ; TIME->W CLRF TMR0 DECFSZ SKIPER,F GOTO WAIT_1 INCF SKIPER,F SUBWF PULS1,W ; CHECK DIFFERENC WITH ONE BEFORE SUBWF PULS1,F BTFSS STATUS,C ADDLW .5 ; IF IS NEGATIVE ADD 5 AND SEE IF IS STILL NEGATIVE ANDLW B'11111000' ; CHECK DIFFERECE WITH PREVIUS CODE BTFSC STATUS,Z ; IS THERE A DIFFERENCE GOTO DIFF_1 MOVF BITMASK,W ; XOR1 IF THERE WAS DIFFERENCE XORWF INDF,F MOVF LENGTH,W ANDLW B'11111100' ; CHECK IF THERE 3 CODES PASSED (HEADER SKIP + BYTES COMPARED WITH HEADERP) BTFSC STATUS,Z GOTO DIFF_1 BSF CODE_TYPE,00 ; FLAG THAT SHOWS THAT THERE WAS DIFFERENC DIFF_1: BCF STATUS,C RRF BITMASK,F ; ROTATE BITMASK USED FOR CIRCULAR XORING BTFSC STATUS,C BSF BITMASK,07 INCF LENGTH,F WAIT_1A: BTFSC PORTB,03 ; EVERITHING BELOW IS SAME AS UP , ONLY IS DONE FOR SPACE GOTO WAIT_1A MOVF TMR0,W CLRF TMR0 SUBWF SPACE1,W SUBWF SPACE1,F BTFSS STATUS,C ADDLW .5 ANDLW B'11111000' BTFSC STATUS,Z ; IS THERE A DIFFERENCE GOTO DIFF_0 MOVF BITMASK,W ; XOR1 IF THERE WAS DIFFERENCE XORWF INDF,F MOVF LENGTH,W ANDLW B'11111100' BTFSC STATUS,Z GOTO DIFF_0 BSF CODE_TYPE,01 DIFF_0: BCF STATUS,C RRF BITMASK,F ; ROTATE BITMASKS USED FOR CIRCULAR XORING BTFSC STATUS,C ; IS MASKBIT SHIFTED OUT ? YES-> SET BITMASK 07 AGAIN BSF BITMASK,07 BTFSC STATUS,C ; IS MASKBIT SHIFTED OUT ? YES -> GOTO NEXT OUTBYTE INCF FSR,F MOVLW OUTBYTE6+1 ; DID WE USED ALL 6 OUTBYTES ? YES->GOTO OUTBYTE1 XORWF FSR,W BTFSS STATUS,Z GOTO NO_FIX_NEEDED ; MOVLW OUTBYTE1 ; MOVWF FSR NO_FIX_NEEDED: INCF LENGTH,F ; LENGTH COUNTER GOTO WAIT_0A ;------------------------------------(GRAB MODE)------------------------- GRAB_MODE: BSF MODE,01 ; SET MODE FLAG MOVLW 'O' ; RS232 OUTPUT REPLY CALL TX96 MOVLW 'G' CALL TX96 GOTO GRAB_PROGRAM_START GRAB_SEND: MOVF LENGTH,W ; IS RECEIVED SIGNAL TOO SHORT ? ANDLW B'1111100' ; THIS WILL PROBABLY KILL STOP SIGNALS THAT SOME REMOTES USE. BTFSC STATUS,Z GOTO GRAB_PROGRAM_START CLRF B14 ; TO BE USED IN FUTURE CLRF B15 ; BITS 0,1,2 USED FOR CARRIER FRQ. BSF B15,2 ; B15 IS USED FOR CARRIER FRQ. SET TO 40.32KHZ ; B1,B2,..,B13 USED FOR CODE -> MAX. 52 BIT REM MOVF H_PULS,W ; SEND DATA COLLECTED CALL TX96 MOVF H_SPACE,W CALL TX96 MOVF PULS_0,W CALL TX96 MOVF PULS_1,W CALL TX96 MOVF SPACE_0,W CALL TX96 MOVF SPACE_1,W CALL TX96 MOVF LENGTH,W CALL TX96 MOVLW B1 MOVWF FSR MOVLW .15 MOVWF GTEMP1 LOOP1: MOVF INDF,W ; SEND CODE CALL TX96 INCF FSR,F DECFSZ GTEMP1,F GOTO LOOP1 ;CLRF TMR0 ;BTFSS TMR0,7 ;GOTO $-1; SIGNAL_EXIST: NOP BTFSS PORTB,03 CLRF TMR0 MOVF TMR0,W XORLW .254 BTFSS STATUS,Z GOTO SIGNAL_EXIST CLRF TMR0 GRAB_PROGRAM_START: MOVLW 00C ; CLEAR MEM MOVWF FSR CLRF INDF INCF FSR,F BTFSS FSR,6 GOTO $-3 CLRF TMR0 BCF INTCON,T0IF ; CLEAR TMR0 INTERUPT FLAG MOVLW b'10100000' ; SET INT. MOVWF INTCON G_WAIT_HP: CLRF TMR0 ; NO SIGNAL WAIT FOR PULS BTFSC PORTB,03 GOTO G_WAIT_HP ; PULS G_WAIT_HS: BTFSS PORTB,03 ; PULS LOOP GOTO G_WAIT_HS MOVF TMR0,W ; SPACE CLRF TMR0 MOVWF H_PULS ; WRITE HEADER PULS (OR NOT?) G_WAIT_P1: BTFSC PORTB,03 ; SPACE LOOP GOTO G_WAIT_P1 MOVF TMR0,W ; PULS CLRF TMR0 MOVWF H_SPACE ; WRITE HEADER SPACE G_WAIT_S1: BTFSS PORTB,03 ; PULS LOOP GOTO G_WAIT_S1 MOVF TMR0,W ; SPACE CLRF TMR0 MOVWF PULS_0 ; WRITE FIRST PULS LENGTH MOVWF PULS_1 ; INCF LENGTH,F G_WAIT_P2: BTFSC PORTB,03 ; SPACE LOOP GOTO G_WAIT_P2 MOVF TMR0,W ; PULSE CLRF TMR0 MOVWF SPACE_0 ; WRITE FIRST SPACE LENGTH MOVWF SPACE_1 ; INCF LENGTH,F CLRF B1 CLRF B2 CLRF B3 CLRF B4 BSF B1,06 BSF B1,07 ;-------- MOVLW B1 MOVWF FSR MOVLW B'00100000' MOVWF BITMASK G_WAIT_SS: BTFSS PORTB,03 ; PULS LOOP GOTO G_WAIT_SS MOVF TMR0,W ; SPACE CLRF TMR0 MOVWF GTEMP1 SUBWF PULS_0,W BTFSS STATUS,C ADDLW .7 ; IF IS NEGATIVE ADD 7 AND SEE IF IS STILL NEGATIVE ANDLW B'11111000' BTFSC STATUS,Z ; IS THERE A DIFFERENCE GOTO G_ITS_P0 ; BCF STATUS,C RRF BITMASK,F MOVF GTEMP1,W MOVWF PULS_1 GOTO G_P_END G_ITS_P0: MOVF BITMASK,W ; XOR1 IF THERE WAS DIFFERENCE XORWF INDF,F BCF STATUS,C RRF BITMASK,F ; ROTATE BITMASK USED FOR CIRCULAR XORING BTFSC STATUS,C BSF BITMASK,07 G_P_END: INCF LENGTH,F ;-- G_WAIT_PP: BTFSC PORTB,03 ; SPACE LOOP GOTO G_WAIT_PP MOVF TMR0,W CLRF TMR0 MOVWF GTEMP1 SUBWF SPACE_0,W BTFSS STATUS,C ADDLW .7 ; IF IS NEGATIVE ADD 7 AND SEE IF IS STILL NEGATIVE ANDLW B'11111000' BTFSC STATUS,Z ; IS THERE A DIFFERENCE GOTO G_ITS_S0 ; BCF STATUS,C RRF BITMASK,F BTFSC STATUS,C ; IS MASKBIT SHIFTED OUT ? YES-> SET BITMASK 07 AGAIN BSF BITMASK,07 BTFSC STATUS,C ; IS MASKBIT SHIFTED OUT ? YES -> GOTO NEXT B? INCF FSR,F MOVF GTEMP1,W MOVWF SPACE_1 GOTO G_S_END ; ***** OPTIMIZIRAT -> BTFSS STATUS,Z PA ONDA XOR ILI NE G_ITS_S0: MOVF BITMASK,W ; XOR1 IF THERE WAS DIFFERENCE XORWF INDF,F BCF STATUS,C RRF BITMASK,F ; BTFSC STATUS,C ; IS MASKBIT SHIFTED OUT ? YES-> SET BITMASK 07 AGAIN BSF BITMASK,07 BTFSC STATUS,C ; IS MASKBIT SHIFTED OUT ? YES -> GOTO NEXT B? INCF FSR,F G_S_END: INCF LENGTH,F GOTO G_WAIT_SS BLABLA GOTO BLABLA ;-----------------------------------------(TRANSMIT MODE)------------------ TRANSMIT_MODE: MOVLW 'O' ; RS232 REPLY CALL TX96 MOVLW 'T' CALL TX96 BSF MODE,02 ; SET MODE (NOT USED IN THIS VERSION) CLRF INTCON ; KILL INTERUPTS CALL RX96 ; RECEIVE DATA (22BYTES NEEDED) MOVWF H_PULS ; NO EXPIRE TIME (PROGRAM WILL LOCK HERE IF LESS THEN 22 BYTES RECEIVED) CALL RX96 MOVWF H_SPACE CALL RX96 MOVWF PULS_0 CALL RX96 MOVWF PULS_1 CALL RX96 MOVWF SPACE_0 CALL RX96 MOVWF SPACE_1 CALL RX96 MOVWF LENGTH MOVLW B1 MOVWF FSR MOVLW .15 MOVWF TEMP4 T_LOOP1: CALL RX96 MOVWF INDF INCF FSR,F DECFSZ TEMP4,F GOTO T_LOOP1 ;------------------------IR TRANSMOTING STARTS MOVF B15,W ANDLW B'00000111' MOVWF FRQ_DLY INCF LENGTH,F SWAPF B15,W ANDLW B'00001111' MOVWF TEMP4 INCF TEMP4,F T_REP: MOVF LENGTH,W MOVWF GTEMP1 MOVF H_PULS,W ; SEND HEADER PULS CALL P40KHZ MOVF H_SPACE,W ; SEND HEADER SPACE CALL S40KHZ MOVLW B1 MOVWF FSR MOVLW B'10000000' MOVWF BITMASK SLOOP: MOVF BITMASK,W ; XOR1 IF THERE WAS DIFFERENCE ANDWF INDF,W BTFSS STATUS,Z GOTO T1 MOVF PULS_1,W ; SET MIN_PULS GOTO TE1 T1: MOVF PULS_0,W TE1: CALL P40KHZ ; SEND SIGNAL TO IR DIODES BCF STATUS,C RRF BITMASK,F MOVF BITMASK,W ANDWF INDF,W BTFSS STATUS,Z GOTO T2 MOVF SPACE_1,W GOTO TE2 T2: MOVF SPACE_0,W TE2: CALL S40KHZ ; SEND SIGNAL TO IR DIODES BCF STATUS,C RRF BITMASK,F BTFSC STATUS,C BSF BITMASK,07 BTFSC STATUS,C INCF FSR,F DECF GTEMP1,F DECFSZ GTEMP1,F GOTO SLOOP CLRF TMR0 BSF STATUS,RP0 MOVLW b'11010111' MOVWF OPTION_REG BCF STATUS,RP0 ABCD1: MOVLW .2 MOVWF TEMP5 CLRF TMR0 AHA: BTFSS TMR0,7 GOTO AHA CLRF TMR0 DECFSZ TEMP5,F GOTO AHA CLRF TMR0 BSF STATUS,RP0 MOVLW b'11010101' MOVWF OPTION_REG BCF STATUS,RP0 DECFSZ TEMP4 GOTO T_REP TR_END: ; ENDLESS LOOP (AFTER SENDING IR SIGNAL, UIRT MUST BE RESTARTED -> CLRRTS->SETRTS ) GOTO TR_END ;------------------------------------------------------------ S40KHZ: ; MODULATION CLRF TMR0 ADDLW .0 ; DUMMY STUFF FOR TESTING MOVWF TEMP1 SPACE_40_L: MOVF TEMP1,W XORWF TMR0,W BTFSS STATUS,Z GOTO SPACE_40_L RETURN PULS40KHZ: ; MODULATION P40KHZ: CLRF TMR0 ;ADDLW .254 ; FOR TESTING MOVWF TEMP1 MOVLW (P40KHZ >> 8) MOVWF PCLATH P40KHZ_L: MOVLW B'00110000' ; IORWF PORTB,F ; MOVF FRQ_DLY,W ANDLW B'00000111' ADDWF PCL,F NOP NOP NOP NOP NOP NOP NOP GOTO $+1 GOTO $+1 ;X NOP ;X MOVLW B'11001111' ; ANDWF PORTB,F ; MOVF FRQ_DLY,W ANDLW B'00000111' ADDWF PCL,F NOP NOP NOP NOP NOP NOP NOP MOVF TEMP1,W ; XORWF TMR0,W ; BTFSS STATUS,Z ; GOTO P40KHZ_L ; RETURN ;------------------LOAD CONFIGURATION LOAD_CFG: MOVLW 'O' CALL TX96 MOVLW 'C' CALL TX96 CALL RX96 MOVWF EE_CFG CALL RX96 MOVWF EE_MASK MOVLW 038H MOVWF EEADR MOVF EE_CFG,W MOVWF EEDATA CALL WRITE_EE INCF EEADR,F MOVF EE_MASK,W MOVWF EEDATA CALL WRITE_EE LC_END: GOTO LC_END ;------------------------SEND CFG--------------- SEND_CFG: MOVLW 'O' CALL TX96 MOVLW 'S' CALL TX96 MOVLW 0x38 CALL EE_READ CALL TX96 MOVLW 0x39 CALL EE_READ CALL TX96 SC_END: GOTO SC_END ;---------------EE WRITE WRITE_EE: BSF STATUS,RP0 BSF EECON1,WREN MOVLW 055H MOVWF EECON2 MOVLW 0AAH MOVWF EECON2 BSF EECON1,WR EEW_WAIT: BTFSC EEDATA,WR GOTO EEW_WAIT BCF STATUS,RP0 RETURN ;------------EE READ--------------------------------- EE_READ: MOVWF EEADR BSF STATUS,RP0 ; SWITCH BANKS BSF EECON1,RD ; READ EE->EEDATA NOP BCF STATUS,RP0 ; BACK TO NORMAL MOVF EEDATA,W ; RETURN ;****************************DEBUG ****************************** DEBUG_REM: BSF MODE,07 MOVLW 'O' CALL TX96 MOVLW 'D' CALL TX96 DD: CLRF TMR0 BCF INTCON,T0IF ; CLEAR TMR0 INTERUPT MOVLW b'10100000' MOVWF INTCON D_WAIT_1: CLRF TMR0 BTFSC PORTB,03 GOTO D_WAIT_1 CLRF TMR0 D_WAIT_0A: BTFSS PORTB,03 GOTO D_WAIT_0A MOVF TMR0,W CLRF TMR0 CALL TX57 D_WAIT_1A: BTFSC PORTB,03 GOTO D_WAIT_1A MOVF TMR0,W CLRF TMR0 CALL TX57 GOTO D_WAIT_0A DEBUG_SEND: CLRF TMR0 MOVLW .255 CALL TX57 CLRF TMR0 GOTO DD DEB_END: GOTO DEB_END ;;;;; Here goes tx rx stuff ------------- TX96: MOVWF BYTE MOVLW 8 ; MOVWF BITCOUNT ; TX_START_BIT: BSF TX_PIN ; 0 MOVLW .31 ; 1 MOVWF DELAY ; 2 NOP TX_BIT: DECFSZ DELAY,F ;3/108 GOTO TX_BIT ;4 MOVLW .31 ; 1 MOVWF DELAY ; 2 RRF BYTE,F ; 3 BTFSS STATUS,C ; 4 GOTO TX_0 ; 5,6 GOTO TX_1 ; 100,101 TX_0: NOP ; 7 NOP ; 8 BSF TX_PIN ; 104 DECFSZ BITCOUNT,F ; 11 GOTO TX_BIT ; 12,13 GOTO TX_STOP_BIT ; 3 TX_1: BCF TX_PIN ; 9 DECFSZ BITCOUNT,F ; 1 GOTO TX_BIT ; 2 NOP ; 3 TX_STOP_BIT: DECFSZ DELAY,F GOTO TX_STOP_BIT NOP ;4 NOP ;5 NOP ;6 NOP ;7 NOP ;8 BCF TX_PIN ;9 MOVLW .34 ; MOVWF DELAY TX_STOP: DECFSZ DELAY,F GOTO TX_STOP RETURN ; ;----------------------------------------------------- RX96: CLRF BYTE ; MOVLW .32 MOVWF DELAY RX_START_BIT: BTFSS RX_PIN ; 0 GOTO RX_START_BIT ; 1 MOVLW 8 ; 2 MOVWF BITCOUNT ; 3 BCF STATUS,C ; 4 NOP ; 5 NOP ; 6 NOP ; 7 NOP ; 8 NOP RX_NEXT_BIT: DECFSZ DELAY,F ;9 GOTO RX_NEXT_BIT ;10,11.. BTFSS RX_PIN ; 104 BSF STATUS,C ; 2 RRF BYTE,F ; 3 BCF STATUS,C ; 4 MOVLW .32 ; 5 MOVWF DELAY ; 6 DECFSZ BITCOUNT,F ; 7 GOTO RX_NEXT_BIT ; 8,9 RX_STOP_BIT: nop nop DECFSZ DELAY,F GOTO RX_STOP_BIT MOVF BYTE,W RETURN ;--------TX 57K/////////////////////////////////////////////////// TX57: MOVWF BYTE TX57_START_BIT: BSF TX_PIN ; 0 NOP ; 1 NOP ; 2 MOVLW 8 ; 3 MOVWF BITCOUNT ; 4 TX57_BIT: NOP ; 5 NOP ; 6 NOP ; 7 NOP ; 8 RRF BYTE,F ; 9 BTFSS STATUS,C ; 10 GOTO TX57_0 ; 11,12 GOTO TX57_1 ; 12,13 TX57_0: NOP ; 13 NOP ; 14 NOP ; 15 NOP ; 16 BSF TX_PIN ; 17->18 NOP ; 1 DECFSZ BITCOUNT,F ; 2 GOTO TX57_BIT ; 3,4 GOTO TX57_STOP_BIT ; 4,5 TX57_1: NOP ; 14 NOP ; 15 NOP ; 16 BCF TX_PIN ; 17->18 NOP ; 1 DECFSZ BITCOUNT,F ; 2 GOTO TX57_BIT ; 3,4 NOP ; 4 NOP ; 5 TX57_STOP_BIT: NOP ; 6 NOP ; 7 NOP ; 8 NOP ; 9 NOP ; 10 NOP ; 11 NOP ; 12 NOP ; 13 NOP ; 14 NOP ; 15 NOP ; 16 BCF TX_PIN ; 17->18 NOP ; 1 NOP ; 2 NOP ; 3 NOP ; 4 NOP ; 5 NOP ; 6 NOP ; 7 NOP ; 8 NIJE NI VAZNO DALJE ! NOP ; 9 NOP ; 10 NOP ; 11 NOP ; 12 NOP ; 13 NOP ; 14 NOP ; 15 RETURN ; 16,17 ;-----------------------------(VERSION INFORMATION - READED FROM EEPROM AND SENDED TO RS232) SHOW_VER: CLRF EEADR ; GO TO BYTE 0 RDL: BSF STATUS,RP0 ; SWITCH BANKS BSF EECON1,RD ; READ EE->EEDATA BCF STATUS,RP0 ; BACK TO NORMAL INCF EEADR,F ; GOTO NEXT EE BYTE MOVF EEDATA,W ; CALL TX96 ; SEND READED BYTE OUT MOVF EEDATA,W XORLW 0FFH BTFSS STATUS,Z ; IS DATA 0FFh GO TO MAIN LOOP (PROGRAM RESTART) GOTO RDL GOTO IR_LOOP org 2100H ; SWITCH TO EE DE "UIRTdp 4Mhz version 1.22 / by Danijel Pticar" ; VER. INFO org 2138H DW B'00000010' DW B'11111111' END ; HAPPY END ? Build completed successfully. Build completed successfully. Build completed successfully. Build completed successfully. Build completed successfully.