; 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 SerialWatcher to see wich code changes. ;!!! Some remotes send code + (code xor ???). ; ; ; ComSetup : 9600,8,1 / Hardware Handshaking : None / SoftwareHandshaking : None ; ; This code can not be used for commercial purpose. ; ; E-MAIL : danijel.pticar@free-zg.t-com.hr / Danijel Pticar ; WWW : http://free-zg.t-com.hr/DPM ; ; !!!!!!! FOR 4MHZ ONLY !!!!!!!! <-------------------- READ THIS !!!!!! ; ; ; ; ; IR - UIR ; IG - GRAB MODE ; IT - TRANSMIT MODE ; IV - VERSION ON RS232 ; IC - LOAD NEW CONFIG TITLE "UIRT FOR PIC-16F627" LIST P=16F627 #include p16F627.inc ;---------------------------------------------------------------------------- __CONFIG _CP_OFF & _PWRTE_OFF & _WDT_OFF & _MCLRE_ON & _XT_OSC & _BODEN_OFF & _LVP_OFF ;-------------------used in UIR MODE-------------- ;AHHH EQU 020H SADR EQU 0x20 ; start adress PULS1 EQU SADR+0x01 SPACE1 EQU SADR+0x02 BITMASK EQU SADR+0x03 ; ****** 038H OUTBYTE1 EQU SADR+0x04 OUTBYTE2 EQU SADR+0x05 OUTBYTE3 EQU SADR+0x06 OUTBYTE4 EQU SADR+0x07 OUTBYTE5 EQU SADR+0x08 OUTBYTE6 EQU SADR+0x09 CODE_TYPE EQU SADR+0x0A SKIPER EQU SADR+0x0B ;------------------------------------------------- ;------------------used in (UIRT-MODE)----------------- H_PULS EQU SADR+0x10 H_SPACE EQU SADR+0x11 PULS_MIN EQU SADR+0x12 PULS_MAX EQU SADR+0x13 SPACE_MIN EQU SADR+0x14 SPACE_MAX EQU SADR+0x15 TEMP1 EQU SADR+0x16 TEMP2 EQU SADR+0x17 LENGTH EQU SADR+0x18 TEMP4 EQU SADR+0x19 FRQ_DLY EQU SADR+0x1A TEMP5 EQU SADR+0x1B B1 EQU SADR+0x1C B2 EQU SADR+0x1D B3 EQU SADR+0x1E B4 EQU SADR+0x1F B5 EQU SADR+0x20 B6 EQU SADR+0x21 B7 EQU SADR+0x22 B8 EQU SADR+0x23 B9 EQU SADR+0x24 B10 EQU SADR+0x25 B11 EQU SADR+0x26 B12 EQU SADR+0x27 B13 EQU SADR+0x28 B14 EQU SADR+0x29 B15 EQU SADR+0x2A B16 EQU SADR+0x2B ;----------------------CONFIGURATION------------------------------- EE_CFG EQU SADR+0x30 EE_MASK EQU SADR+0x31 ;----------------------------------------------------- PULS_0 EQU SADR+0x32 PULS_1 EQU SADR+0x33 SPACE_0 EQU SADR+0x34 SPACE_1 EQU SADR+0x35 GTEMP1 EQU SADR+0x36 ;--------------------GENERAL STUFF - MODE EQU SADR+0x37 ; USED FOR FLAGS TO SEE IN WICH MODE WE ARE (UIR,UIRT-R,UIRT-S) BYTE EQU SADR+0x38 BITCOUNT EQU SADR+0x39 DELAY EQU SADR+0x3A ED EQU 0x70 EA EQU 0x71 ;--------------------input, output rs232 pins #define TX_PIN PORTB,07 #define RX_PIN PORTB,06 #define IR_PIN PORTB,03 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 ;BSF MODE,00 ;GOTO UIR_PROGRAM_START ;GOTO SEND_CODE 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 BSF STATUS,RP0 ; SWITCH BANKS MOVWF EEADR BSF EECON1,RD ; READ EE->EEDATA MOVF EEDATA,W ; MOVWF ED BCF STATUS,RP0 ; BACK TO NORMAL ANDLW B'11111011' BTFSS STATUS,Z GOTO NOT_MASK MOVLW 039H BSF STATUS,RP0 ; SWITCH BANKS MOVWF EEADR BSF EECON1,RD ; READ EE->EEDATA MOVF EEDATA,W ; MOVWF ED BCF STATUS,RP0 ; BACK TO NORMAL ANDWF OUTBYTE1,F GOTO SEND_OUT NOT_MASK: MOVF ED,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 CLRF OUTBYTE1 CLRF OUTBYTE2 CLRF OUTBYTE3 CLRF OUTBYTE4 CLRF OUTBYTE5 CLRF OUTBYTE6 CLRF LENGTH CLRF PULS1 CLRF SPACE1 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 IR_PIN GOTO WAIT_1 CLRF TMR0 ; PULS ARIVED CLEAR TIMER AND STAR COUNTING MOVLW OUTBYTE1 MOVWF FSR WAIT_0A: BTFSS IR_PIN ; 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 IR_PIN ; 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 -> MIN. 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 IR_PIN 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 IR_PIN GOTO G_WAIT_HP ; PULS G_WAIT_HS: BTFSS IR_PIN ; PULS LOOP GOTO G_WAIT_HS MOVF TMR0,W ; SPACE CLRF TMR0 MOVWF H_PULS ; WRITE HEADER PULS (OR NOT?) G_WAIT_P1: BTFSC IR_PIN ; SPACE LOOP GOTO G_WAIT_P1 MOVF TMR0,W ; PULS CLRF TMR0 MOVWF H_SPACE ; WRITE HEADER SPACE G_WAIT_S1: BTFSS IR_PIN ; 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 IR_PIN ; 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 IR_PIN ; 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 IR_PIN ; 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,F 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 EA MOVF EE_CFG,W MOVWF ED CALL WRITE_EE INCF EA,F MOVF EE_MASK,W MOVWF ED 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 MOVF EA,W MOVWF EEADR MOVF ED,W MOVWF EEDATA BSF EECON1,WREN MOVLW 055H MOVWF EECON2 MOVLW 0AAH MOVWF EECON2 BSF EECON1,WR EEW_WAIT: BTFSC EECON1,WR GOTO EEW_WAIT BCF EECON1,WREN BCF STATUS,RP0 RETURN ;------------EE READ--------------------------------- EE_READ: BSF STATUS,RP0 ; SWITCH BANKS MOVWF EEADR BSF EECON1,RD ; READ EE->EEDATA NOP MOVF EEDATA,W ; BCF STATUS,RP0 ; BACK TO NORMAL 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 IR_PIN GOTO D_WAIT_1 CLRF TMR0 D_WAIT_0A: BTFSS IR_PIN GOTO D_WAIT_0A MOVF TMR0,W CLRF TMR0 CALL TX57 D_WAIT_1A: BTFSC IR_PIN 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) ; this is not working for 16F627 - have to be fixed SHOW_VER: ; GO TO BYTE 0 RDL: BSF STATUS,RP0 ; SWITCH BANKS CLRF EEADR 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 v1.22 16F627 / by Danijel Pticar" ; VER. INFO org 2138H DW B'00000010' DW B'11111111' END ; HAPPY END ? Build completed successfully. Build completed successfully.