;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; 6-CAMERA CCTV SWITCHER ; ; ; ; AUTHOR: S.DAS GUPTA ; ; Mobile: 9910647733 ; ; E-mail:powertech777@yahoo.co.in ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;************************************************ ;DATED: 05-09-2007 \ finalised:XX-XX-XXXX * ;D:\a-micro\cctv-efy\cctv_6.asm * ;p-16f73 / crystal:4MHZ * ;Program Memory Words Used: * ;Program Memory Words Free: * ;************************************************ LIST P=PIC16f72 #INCLUDE "P16F72.INC" ; __FUSES _XT_OSC & _PWRTE_ON & _WDT_OFF & _CP_OFF ;errorlevel -203,-302,-305,-306 ; ***** Variables Definitions ***** SELFCHECK macro a, bxx movlw bxx xorwf a,0 btfsc STATUS,Z endm SELFCHECKR macro C,D movf C,0 xorwf D,0 btfsc STATUS,Z endm RAMbase equ 0x60 CBLOCK RAMbase TEMP flags W_Temp S_Temp T_Temp RC5_Bit_Count RC5_Command PASSDUMMY ones_1 tens_1 tens_ones camera R1 R2 R3 R4 DUMMY BCDCAL R11 R22 R33 r44 ra rb R5 volume r6 r7 r17 r18 endc RS EQU 3 EN EQU 2 #DEFINE LCDPORT PORTB edit EQU 0X20 auto EQU 0X21 TENS EQU 0X22 ONES EQU 0X23 cam_del_1 EQU 0X24 PUTU EQU 0X25 cam_del_2 EQU 0X26 cam_del_3 EQU 0X27 cam_del_4 EQU 0X28 cam_del_5 EQU 0X29 cam_del_6 EQU 0X30 DUMMY2 EQU 0X45 HUNS EQU 0X46 r9 equ 0X47 r8 equ 0X48 r10 equ 0X55 r12 equ 0X56 r13 equ 0X57 r14 equ 0X58 r15 equ 0X59 ; ***** Definitions ***** #define Last_RC5_Bit flags,1 ; Last RC5 bit received #define RC5_2nd_Bit flags,2 ; Add 2 RC5 bits #define RC5_2nd_Value flags,3 ; 2nd RC5 bit received #define RC5_Bit flags,4 ; 1st RC5 bit received #define SEL_BANK_0 bcf STATUS,RP0 ; Select Bank 0 #define SEL_BANK_1 bsf STATUS,RP0 ; Select Bank 1 #define CARRY STATUS,C #define ZERO STATUS,Z ; ***** RESET ***** org 0000h Reset_Vector ; Indicate Reset was OK ; Initialise RC5 goto Main_Start ; Skip Interrupt Routines org 0x004 ; ***** INTERRUPT ***** Interrupt_Vector if (Interrupt_Vector != 0x004 ) ERROR "Warning Interrupts must start at address 0x004" endif Push movwf W_Temp ; Save W swapf STATUS,W movwf S_Temp ; Save STATUS SEL_BANK_0 Disable_Int bcf INTCON,GIE ; Disable all Interrupts btfsc INTCON,GIE ; Are Interrupts disabled ? goto Disable_Int ; NO, try again btfsc INTCON,INTF ; Skip PORTB0/Interrupt? goto RB0_Int ; NO, goto RB0 btfsc INTCON,T0IF ; Skip Timer Overflow Interrupt ? goto Timer_Int ; NO, goto Timer Interrupt Pop swapf S_Temp,W movwf STATUS ; Return STATUS swapf W_Temp,F swapf W_Temp,W ; Return W retfie ; Return setting GIE ; ***** RB0/INT RC5 Interrupt ***** RB0_Int bcf INTCON,T0IE ; Disable further Timer0 Interrupts bcf INTCON,T0IF ; Clear Overflow Flag movf TMR0,W ; Get Timer Value movwf T_Temp ; And rescue movlw b'00000011' ; W takes 1:16 clrf TMR0 SEL_BANK_1 iorwf OPTION_REG,F ; 1:16 SEL_BANK_0 bcf RC5_2nd_Bit ; ***** First Bit ??? ****** movf RC5_Bit_Count,F btfsc ZERO goto RC5_Add_1 ; ***** Decide which window contains T_Temp [ <> 8C <> CF <> ] movlw 0X8c ;value for 4MHZ crystal ;movlw 0X46 ;VALUE FOR 2MHZ CRYSTAL ;movlw 0x23 ; Changed values for 1MhZ subwf T_Temp,W ; Carry will be cleared if T_Temp < 8C ie 2T btfss CARRY ; Skip if >= 8C goto Timer_is_2T ; must be >= 8C movlw 0XCF ; value for 4MHZ crystal ;movlw 0X68 ; Idem with CF(VALUE FOR 2MHx CRYSTAL) ;movlw 0x34 ; Changed values for 1MhZ subwf T_Temp,W btfss CARRY goto Timer_is_3T Timer_is_4T btfss Last_RC5_Bit ; Was last bit "1" ? goto RC5_Rx_Error ; No, was "0", error! goto RC5_Add_01 ; Last bit was "1", add "01" Timer_is_2T btfss Last_RC5_Bit ; Was last bit "1" ? goto RC5_Add_0 ; No, was "0", add "0" goto RC5_Add_1 ; No, was "1", add "1" Timer_is_3T btfss Last_RC5_Bit ; Was last bit "1" ? goto RC5_Add_1 ; No, was "0", add "1" goto RC5_Add_00 ; Last bit was "1", add "00" ; ***** If Two Bits must be added, the first one is always a 0 RC5_Add_01 bsf RC5_2nd_Value goto RC5_Add_0X RC5_Add_00 bcf RC5_2nd_Value RC5_Add_0X bsf RC5_2nd_Bit RC5_Add_0 bcf RC5_Bit goto RC5_Add_Bit RC5_Add_1 bsf RC5_Bit ;BSF PORTB,1 ;GOTO $ RC5_Add_Bit btfss RC5_Bit ; Save bit for future goto RC5_was_0 ; bsf Last_RC5_Bit ; goto RC5_Test_End ; RC5_was_0 ; bcf Last_RC5_Bit ; RC5_Test_End ; Bit saved. incf RC5_Bit_Count,F ; Increment Bit Count movlw d'2' ; Test if RC5 bit extended (bit 2) subwf RC5_Bit_Count,W btfsc ZERO ; If extended bit then goto RC5_Command_Rotate ; add extended bit to Command movlw d'9' ; Test Bit Count for >= 9 subwf RC5_Bit_Count,W ; Carry will be set if >= 9 btfss CARRY ; Skip if >= 9 goto RC5_Add_Bit_End RC5_Command_Rotate rlf RC5_Command ; RC5 Command Section bcf RC5_Command,0 btfsc RC5_Bit ; Skip next if 0 bsf RC5_Command,0 RC5_Add_Bit_End btfss RC5_2nd_Bit ; Add two bits ? goto RC5_Int_End ; No, End Interrupt bcf RC5_2nd_Bit ; Two bits, now one bit! btfsc RC5_2nd_Value ; Second bit is 0 ? goto RC5_Add_1 ; No, add a 1 goto RC5_Add_0 ; Yes, add a 0 RC5_Rx_Error RC5_Int_End bsf INTCON,T0IE ; Enable Timer0 Interrupts bcf INTCON,INTF ; Clear Interrupt PortB Flag goto Pop ; Quit via POP Timer_Int ; RC5 Time of the Truth bcf INTCON,T0IE ; Disable further Timer0 Interrupts bcf INTCON,T0IF ; Clear Overflow movlw d'13' ; Test Bit Count = 13 subwf RC5_Bit_Count,W ; Zero will be set if Count = 13 btfss ZERO ; Skip if = 13, will need to add a 0 goto No_Zero_Needed incf RC5_Bit_Count,F ; Increment Bit Count rlf RC5_Command ; RC5 Command Section bcf RC5_Command,0 No_Zero_Needed movlw b'01000000' ; Do some cosmetics: xorwf RC5_Command,F ; Put extended above normal commands movf RC5_Command,W ; Get Command movwf PASSDUMMY ;movf PASSDUMMY,0 ;movwf BCDCAL ;added2, shows the display in first column/line only ;call DISPLAY ;goto RC5_Timer_Reset bsf PORTB,1 ;bcf PORTC,2 movlw 0Xff ;VALUE FOR 4MHZ CRYSTAL movwf r9 cloopc call delay2 decfsZ r9,f goto cloopc ;************************************************ ; FUNCTIONAL CODES ARE HERE * ; * ;************************************************ SELFCHECK PASSDUMMY,00h ; decoding 0 - 9 number keys goto num_entry_1 ; on remote SELFCHECK PASSDUMMY,01h goto num_entry_1 SELFCHECK PASSDUMMY,02h goto num_entry_1 SELFCHECK PASSDUMMY,03h goto num_entry_1 SELFCHECK PASSDUMMY,04h goto num_entry_1 SELFCHECK PASSDUMMY,05h goto num_entry_1 SELFCHECK PASSDUMMY,06h goto num_entry_1 SELFCHECK PASSDUMMY,10h ;decoding volume-up key on remote GOTO time_up SELFCHECK PASSDUMMY,11h ;dcoding volume-dn key on remote goto time_dn SELFCHECK PASSDUMMY,0Ch ;decoding '12' pwr key on remote GOTO pwr_std_by SELFCHECK PASSDUMMY,20h ;dcoding CH-UP key on remote goto cam_up SELFCHECK PASSDUMMY,21h ;decoding CH-DN key on remote goto cam_dn SELFCHECK PASSDUMMY,0dh ;decoding MUTE key on remote goto auto_mode SELFCHECK PASSDUMMY,38h ;decoding TV/AV key on remote goto edit_mode ;***************************************************** RC5_was_Err RC5_Timer_Reset bsf Last_RC5_Bit clrf RC5_Bit_Count clrf RC5_Command goto Pop ; Quit via POP ;**************************************************** pwr_std_by btfss PORTC,3 ;if portc,6 is low then goto page_1 goto page_1 ; if it is high then call page_2 goto page_2 num_entry_1 btfss r18,1 goto num_entry_1_y goto RC5_Timer_Reset num_entry_1_y btfss auto,1 goto num_entry_1_x goto RC5_Timer_Reset num_entry_1_x movf PASSDUMMY,0 btfss PORTC,3 goto num_x goto RC5_Timer_Reset num_x movwf ones_1 SELFCHECK ones_1,01h goto cam_1 SELFCHECK ones_1,02h goto cam_2 SELFCHECK ones_1,03h goto cam_3 SELFCHECK ones_1,04h goto cam_4 SELFCHECK ones_1,05h goto cam_5 SELFCHECK ones_1,06h goto cam_6 clear_1 clrf tens_ones clrf ones_1 clrf tens_1 clrf PASSDUMMY call Init_RC5 return disp_clr call paltu movlw '-' call PUTCHAR movlw '-' call PUTCHAR call DELAY goto cam_1 paltu movlw 0X87 call CMD return ax_1 call PUTCHAR movlw ' ' call PUTCHAR return ex_2_a movwf BCDCAL movwf camera call DISPLAY_2 return ;*************************************************** cam_1 call c_1_a call cdl_x_1 return cam_2 call c_2_a call cdl_x_2 return cam_3 call c_3_a call cdl_x_3 return cam_4 call c_4_a call cdl_x_4 return cam_5 call c_5_a call cdl_x_5 return cam_6 call c_6_a call cdl_x_6 return c_1_a movlw 0X01 call ex_2_a movlw b'10000000' movwf PORTC return c_2_a movlw 0X02 call ex_2_a movlw b'01000000' movwf PORTC return c_3_a movlw 0X03 call ex_2_a movlw b'00100000' movwf PORTC return c_4_a movlw 0X04 call ex_2_a movlw b'00010000' movwf PORTC return c_5_a movlw 0X05 call ex_2_a movlw b'00000010' movwf PORTC return c_6_a movlw 0X06 call ex_2_a movlw b'00000001' movwf PORTC return mistu movwf BCDCAL call DISPLAY call clear_1 call DELAY bcf r18,1 return cdl_x_1 movf cam_del_1,0 call mistu RETURN cdl_x_2 movf cam_del_2,0 call mistu RETURN cdl_x_3 movf cam_del_3,0 call mistu RETURN cdl_x_4 movf cam_del_4,0 call mistu RETURN cdl_x_5 movf cam_del_5,0 call mistu RETURN cdl_x_6 movf cam_del_6,0 call mistu RETURN cam_up btfss PORTC,3 goto cam_up_2 goto RC5_Timer_Reset cam_up_2 btfss auto,1 goto cam_up_3 goto RC5_Timer_Reset cam_dn btfss PORTC,3 goto cam_dn_2 goto RC5_Timer_Reset cam_dn_2 btfss auto,1 goto cam_dn_3 goto RC5_Timer_Reset c_1 call Init_RC5 movf cam_del_1,0 SELFCHECK cam_del_1,00 return call delay_x return c_2 call Init_RC5 movf cam_del_2,0 SELFCHECK cam_del_2,00 return call delay_x return c_3 call Init_RC5 movf cam_del_3,0 SELFCHECK cam_del_3,00 return call delay_x return c_4 call Init_RC5 movf cam_del_4,0 SELFCHECK cam_del_4,00 return call delay_x return c_5 call Init_RC5 movf cam_del_5,0 SELFCHECK cam_del_5,00 return call delay_x return c_6 call Init_RC5 movf cam_del_6,0 SELFCHECK cam_del_6,00 return call delay_x return cam_dl_1 call c_1_a call c_1 return cam_dl_2 call c_2_a call c_2 return cam_dl_3 call c_3_a call c_3 return cam_dl_4 call c_4_a call c_4 return cam_dl_5 call c_5_a call c_5 return cam_dl_6 call c_6_a call c_6 return edit_mode btfss PORTC,3 goto edit_2 goto RC5_Timer_Reset edit_2 btfss edit,1 goto edit_1 goto page_2 edit_1 bsf edit,1 ;bcf auto,1 movlw 0X8A call CMD movlw '(' call PUTCHAR movlw 'E' call PUTCHAR movlw 'D' call PUTCHAR movlw 'I' call PUTCHAR movlw 'T' call PUTCHAR movlw ')' call PUTCHAR goto cam_1 ;return time_up btfss edit,1 goto RC5_Timer_Reset goto TIME_UP_2 time_dn btfss edit,1 goto RC5_Timer_Reset goto TIME_DN_2 auto_mode btfss PORTC,3 goto auto_Z goto RC5_Timer_Reset auto_Z btfss auto,1 goto auto_2 goto page_2 auto_2 movlw 0X8A call CMD movlw '[' call PUTCHAR movlw 'A' call PUTCHAR movlw 'U' call PUTCHAR movlw 'T' call PUTCHAR movlw 'O' call PUTCHAR movlw ']' call PUTCHAR bsf auto,1 call DELAY goru call cam_dl_1 call cam_dl_2 call cam_dl_3 call cam_dl_4 call cam_dl_5 call cam_dl_6 goto goru ;return goto page_1 page_2 call Init_RC5 call RESET1 movlw 'C' call PUTCHAR movlw 'A' call PUTCHAR movlw 'M' call PUTCHAR movlw 'E' call PUTCHAR movlw 'R' call PUTCHAR movlw 'A' call PUTCHAR movlw ':' call PUTCHAR movlw 0X8A call CMD movlw 'M' call PUTCHAR movlw 'A' call PUTCHAR movlw 'N' call PUTCHAR movlw 'U' call PUTCHAR movlw 'A' call PUTCHAR movlw 'L' call PUTCHAR movlw 0XC2 call CMD movlw 'T' call PUTCHAR movlw 'I' call PUTCHAR movlw 'M' call PUTCHAR movlw 'E' call PUTCHAR movlw ':' call PUTCHAR movlw 0XCB call CMD movlw 's' call PUTCHAR movlw 'e' call PUTCHAR movlw 'c' call PUTCHAR bcf edit,1 bcf auto,1 bcf PORTC,3 clrf r44 call cam_1 return page_1 call RESET1 ;bcf portc,2 movlw 0X82 call CMD movlw 'E' call PUTCHAR movlw 'l' call PUTCHAR movlw 'e' call PUTCHAR movlw 'c' call PUTCHAR movlw 't' call PUTCHAR movlw 'r' call PUTCHAR movlw 'o' call PUTCHAR movlw 'n' call PUTCHAR movlw 'i' call PUTCHAR movlw 'c' call PUTCHAR movlw 's' call PUTCHAR movlw 0Xc4 call CMD movlw 'F' call PUTCHAR movlw 'o' call PUTCHAR movlw 'r' call PUTCHAR movlw ' ' call PUTCHAR movlw 'Y' call PUTCHAR movlw 'o' call PUTCHAR movlw 'u' call PUTCHAR call Init_RC5 clrf PORTC clrf BCDCAL bcf auto,1 bcf edit,1 clrf camera clrf r44 bcf PORTC,2 bsf PORTC,3 call DELAYT call DELAYT call DELAYT call DELAYT call DELAYT call DELAYT call RESET1 movlw 0X84 call CMD MOVLW '6' CALL PUTCHAR MOVLW '-' CALL PUTCHAR movlw 'C' call PUTCHAR movlw 'A' call PUTCHAR MOVLW 'M' call PUTCHAR MOVLW 'E' call PUTCHAR MOVLW 'R' call PUTCHAR MOVLW 'A' call PUTCHAR movlw 0Xc1 call CMD movlw 'C' CALL PUTCHAR movlw 'C' call PUTCHAR movlw 'T' call PUTCHAR movlw 'V' call PUTCHAR movlw 0Xc7 call CMD movlw 'S' call PUTCHAR movlw 'W' call PUTCHAR movlw 'I' call PUTCHAR movlw 'T' call PUTCHAR movlw 'C' call PUTCHAR movlw 'H' call PUTCHAR movlw 'E' call PUTCHAR movlw 'R' call PUTCHAR return ; ************************* ; ***** Main Program ****** ; ************************* Main_Start call Init_LCD ; Initialise LCD call Init_RC5 bsf STATUS,RP0 bsf TRISB,0 bcf TRISB,1 ;bcf STATUS,RP0 ;bsf STATUS,RP0 clrf TRISC ;bcf STATUS,RP0 ;bsf STATUS,RP0 ;clrf TRISA bcf STATUS,RP0 clrf PORTC ;clrf PORTA clrf BCDCAL bcf auto,1 bcf edit,1 clrf camera movlw d'05' movwf cam_del_1 movwf cam_del_2 movwf cam_del_3 movwf cam_del_4 movwf cam_del_5 movwf cam_del_6 call page_1 main_loop ;movlw 0x05 ;call setloc ;movf BCDCAL,0 ;call display goto main_loop ; ***** Initialise RC5 ***** Init_RC5 bsf Last_RC5_Bit clrf RC5_Bit_Count clrf RC5_Command ; ***** Set up Timer for RC5 SEL_BANK_0 bcf INTCON,T0IE ; No Timer Interrupts clrwdt ; Clear WDT SEL_BANK_1 movlw b'11010000' andwf OPTION_REG,F ; Clear Timer Options SEL_BANK_1 bcf OPTION_REG,INTEDG ; Interrupt on falling edge (eg. SFH505) ;bsf OPTION_REG,INTEDG ; Interrupt on rising edge (eg. TDA3047) SEL_BANK_0 bsf INTCON,INTE ; Enable RB0/INT bsf INTCON,GIE ; Enable Interrupts Global return ; ***** InitialiZe LCD ***** Init_LCD CLRF STATUS ;BSF STATUS,RP0 ;******************** ; lcd initialiZation ;******************** BSF STATUS, RP0 BCF STATUS, RP1 CLRF TRISB ;set port b as output port BCF STATUS,RP0 MOVF LCDPORT,0 CLRF LCDPORT BCF LCDPORT,EN ;****************************************************** ; CALL DELAY15MSL ;call delay 15 ms for power up to 5V ; MOVLW 0X30 ; CALL INITCMD ;****************************************************** ; MOVLW 0X30 ; CALL INITCMD ;****************************************************** ; MOVLW 0X30 ; II STEP ; CALL INITCMD ;*********************************************************** ; MOVLW 0X20 ; FUNCTION SET data transfer in 4 bit mode ; CALL INITCMD ;*********************************************************** MOVLW 0X28 ; CALL CMD CALL DELAY ;************** ; DISPLAY OFF * ;************** ; MOVLW 0X08 ; CALL CMD ; II STEP ; CALL DELAY5MSL ; CALL 1.64 mS DELAY ;*************** ; DISPLAY ON * ;*************** MOVLW 0X0F CALL CMD CALL DELAY ; CALL 1.64 mS DELAY ;******************** ; ENTRY MODE SET * ;******************** MOVLW 0X06 ; CALL CMD CALL DELAY MOVLW 0X01 ; CALL CMD CALL DELAY MOVLW 0X80 ; CALL CMD CALL DELAY ;**************************************** ;ANDLW 0X00000011B ;MOVWF LCDPORT ; STORING PORT B BVALUES ;**************************************** ; INITIALIZATION CODE END HERE * ;**************************************** return ;***************************************** DELAY1U6 BCF STATUS,RP0 MOVLW 0XFA MOVWF R1 LOOPX1: NOP DECFSZ R1,1 GOTO LOOPX1 RETURN DELAY: BCF STATUS, RP0 MOVLW 0X1F MOVWF R2 LOOPZ: CALL DELAY1U6 DECFSZ R2,1 GOTO LOOPZ RETURN DELAYT BCF STATUS, RP0 MOVLW 0X04 MOVWF R5 LOOPT: CALL DELAY DECFSZ R5,1 GOTO LOOPT RETURN ;******************************************************** DISPLAY: CALL ASCIICONV CALL DISPNUM ;movlw ' ' ;call PUTCHAR RETURN DISPNUM: movlw 0XC7 ;position of hundred in LCD call CMD movf HUNS,0 call PUTCHAR movlw 0XC8 ;position of tens in LCD call CMD MOVF TENS,0 CALL PUTCHAR movlw 0XC9 ;position of ones in LCD call CMD MOVF ONES,0 CALL PUTCHAR RETURN ASCIICONV: MOVLW '0' MOVWF HUNS MOVWF TENS MOVWF ONES HUNSSET MOVLW 0X64 SUBWF BCDCAL,1 BTFSS STATUS,C GOTO TENSSET INCF HUNS,1 GOTO HUNSSET TENSSET: MOVLW 0X64 ADDWF BCDCAL,1 ;(restore value) TENSET2 MOVLW 0XA SUBWF BCDCAL,1 BTFSS STATUS,C GOTO ONESSET INCF TENS,1 GOTO TENSET2 ONESSET: MOVLW 0XA ADDWF BCDCAL,0 ADDLW '0' MOVWF ONES RETURN PUTCHAR: ; MOVWF DUMMY2 ; MOVF LCDPORT,0 ; MOVWF DUMMY ; BSF LCDPORT,RS ; MOVF DUMMY2,0 ; ANDLW 0XF0 ; MOVWF LCDPORT ; BSF LCDPORT,RS ; do not alter rs bit or en bit ; BSF LCDPORT,EN ; BCF LCDPORT,EN ; SWAPF DUMMY2,0 ; ANDLW 0XF0 ; MOVWF DUMMY2 ; BSF DUMMY2,RS ; MOVF DUMMY2,0 ; MOVWF LCDPORT ; BSF LCDPORT,EN ; BCF LCDPORT,EN ; CALL DELAY40 ; MOVF DUMMY,0 ; ;ANDLW 0X00000011B ; ;MOVWF LCDPORT ; STORING PORT B BVALUES ; RETURN BANKSEL PORTB MOVWF DUMMY MOVF DUMMY,0 ANDLW 0XF0 MOVWF PORTB BSF PORTB,3 ;CALL ENABLE BSF LCDPORT,EN BCF LCDPORT,EN SWAPF DUMMY,0 ;MOVF TEMP,W ;SWAPF DUMMY2,0 ANDLW 0XF0 MOVWF DUMMY BSF DUMMY,3 MOVF DUMMY,0 MOVWF PORTB ;CALL ENABLE BSF LCDPORT,EN BCF LCDPORT,EN CALL DELAY RETURN CMD: ; MOVWF DUMMY2 ; MOVF LCDPORT,0 ; MOVWF DUMMY ; BCF LCDPORT,RS ; MOVF DUMMY2,0 ; ANDLW 0XF0 ; MOVWF LCDPORT ; BCF LCDPORT,RS ; do not alter rs bit or en bit ; BSF LCDPORT,EN ; BCF LCDPORT,EN ; SWAPF DUMMY2,0 ; ANDLW 0XF0 ; MOVWF DUMMY2 ; BCF DUMMY2,RS ; MOVF DUMMY2,0 ; MOVWF LCDPORT ; BSF LCDPORT,EN ; BCF LCDPORT,EN ; CALL DELAY40 ; ANDLW B'00000011' ; MOVWF LCDPORT ; STORING PORT B BVALUES ; RETURN BANKSEL PORTB MOVWF DUMMY MOVF DUMMY,0 ANDLW 0XF0 MOVWF PORTB BCF PORTB,3 ;CALL ENABLE BSF LCDPORT,EN BCF LCDPORT,EN SWAPF DUMMY,0 ;MOVF TEMP,W ;SWAPF DUMMY2,0 ANDLW 0XF0 MOVWF DUMMY BCF DUMMY,3 MOVF DUMMY,0 MOVWF PORTB ;CALL ENABLE BSF LCDPORT,EN BCF LCDPORT,EN CALL DELAY RETURN ;***************************** INITCMD: MOVWF LCDPORT BSF LCDPORT,EN ; ENABLE PIN ACTIVATED BCF LCDPORT,EN CALL DELAY5MSL RETURN ;**************************** RESET1: MOVLW 0X01 CALL CMD CALL DELAY ;DELAY5MSL RETURN ;**************************** SETLOC: ADDLW 0X80 CALL CMD RETURN ;**************************** DISPLAY_2: CALL ASCIICONV CALL DISPNUM_2 ;movlw ' ' ;call PUTCHAR RETURN DISPNUM_2: ;movlw 0XC5 ;position of hundred in LCD ;call CMD ;movf huns,0 ;call PUTCHAR movlw 0X87 ;position of tens in LCD call CMD MOVF TENS,0 CALL PUTCHAR movlw 0X88 ;position of ones in LCD call CMD MOVF ONES,0 CALL PUTCHAR RETURN ;********************************** DISPLAY_3: CALL ASCIICONV CALL DISPNUM_3 return DISPNUM_3: ;movlw 0XCD ;position of hundred in LCD ;call CMD ;movf huns,0 ;call PUTCHAR movlw 0XCD ;position of tens in LCD call CMD MOVF TENS,0 CALL PUTCHAR movlw 0XCE ;position of ones in LCD call CMD MOVF ONES,0 CALL PUTCHAR RETURN ;********************************* DISPLAY_4: CALL ASCIICONV CALL DISPNUM_4 return DISPNUM_4: movlw 0XCD ;position of hundred in LCD call CMD movf HUNS,0 call PUTCHAR movlw 0XCE ;position of tens in LCD call CMD MOVF TENS,0 CALL PUTCHAR movlw 0XCF ;position of ones in LCD call CMD MOVF ONES,0 CALL PUTCHAR RETURN ;********************* ;delay routines here * ;********************* DELAY40 MOVLW 0X28 MOVWF R11 DLOOP1: DECFSZ R11,1 GOTO DLOOP1 RETURN ;********************* DELAY5MSL ;return MOVLW 0X7D MOVWF R22 DLOOP2: CALL DELAY40 DECFSZ R22,1 GOTO DLOOP2 RETURN ;********************** DELAY15MSL MOVLW 0X03 MOVWF R33 DLOOP3: CALL DELAY5MSL DECFSZ R33,1 GOTO DLOOP3 RETURN delay2 bcf STATUS,RP0 movlw 0X7f movwf r8 loopZ2: decfsZ r8,f goto loopZ2 return delay_x bcf STATUS,RP0 movwf r44 loopk btfss auto,1 goto RC5_Timer_Reset movf r44,0 movwf BCDCAL call DISPLAY call DELAYT decfsZ r44 goto loopk return TIME_UP_2 SELFCHECK camera,01 goto cdl_1_x SELFCHECK camera,02 goto cdl_2_x SELFCHECK camera,03 goto cdl_3_x SELFCHECK camera,04 goto cdl_4_x SELFCHECK camera,05 goto cdl_5_x SELFCHECK camera,06 goto cdl_6_x GOTO RC5_Timer_Reset TIME_DN_2 SELFCHECK camera,01 goto cdl_1_y SELFCHECK camera,02 goto cdl_2_y SELFCHECK camera,03 goto cdl_3_y SELFCHECK camera,04 goto cdl_4_y SELFCHECK camera,05 goto cdl_5_y SELFCHECK camera,06 goto cdl_6_y GOTO RC5_Timer_Reset cdl_1_x incf cam_del_1 movf cam_del_1,0 goto display_x cdl_2_x incf cam_del_2 movf cam_del_2,0 goto display_x cdl_3_x incf cam_del_3 movf cam_del_3,0 goto display_x cdl_4_x incf cam_del_4 movf cam_del_4,0 goto display_x cdl_5_x incf cam_del_5 movf cam_del_5,0 goto display_x cdl_6_x incf cam_del_6 movf cam_del_6,0 goto display_x display_x movwf BCDCAL ;goto display_a call DISPLAY goto RC5_Timer_Reset cdl_1_y decf cam_del_1 movf cam_del_1,0 goto display_x cdl_2_y decf cam_del_2 movf cam_del_2,0 goto display_x cdl_3_y decf cam_del_3 movf cam_del_3,0 goto display_x cdl_4_y decf cam_del_4 movf cam_del_4,0 goto display_x cdl_5_y decf cam_del_5 movf cam_del_5,0 goto display_x cdl_6_y decf cam_del_6 movf cam_del_6,0 goto display_x cam_up_3 SELFCHECK camera,d'01' goto cam_2_x SELFCHECK camera,d'02' goto cam_3_x SELFCHECK camera,d'03' goto cam_4_x SELFCHECK camera,d'04' goto cam_5_x SELFCHECK camera,d'05' goto cam_6_x SELFCHECK camera,d'06' goto cam_1_x cam_1_x bsf r18,1 ;call page_0 goto cam_1 cam_2_x bsf r18,1 ;call page_0 goto cam_2 cam_3_x bsf r18,1 ;call page_0 goto cam_3 cam_4_x bsf r18,1 ;call page_0 goto cam_4 cam_5_x bsf r18,1 ;call page_0 goto cam_5 cam_6_x bsf r18,1 ;call page_0 goto cam_6 cam_dn_3 SELFCHECK camera,d'01' goto cam_6_x SELFCHECK camera,d'02' goto cam_1_x SELFCHECK camera,d'03' goto cam_2_x SELFCHECK camera,d'04' goto cam_3_x SELFCHECK camera,d'05' goto cam_4_x SELFCHECK camera,d'06' goto cam_5_x END