Content-ID: <0_1203_875559925@emout01.mail.aol.com.7744> Content-type: text/plain Lee when I first started to program '84 had all of these problems I found a soulition I can not explain it very well but see attached code segments THEY WORK. note the positioning of the table at the start of the second page of rom the table must be 256 or less bits long else LaLa land is easy to visit !! Attached is a file which contains loads of LCD routienes IT works. Cheers Steve....... POINT MACRO INCF TABOFF,1 MOVFW TABOFF ADDWF PCL,1 ENDM ;------------------PAGE SWITCHING FOR 16C84---------------------------- PAGE0 MACRO BCF PCLATH,1 ; SELECT ROM PAGE 0 ENDM PAGE1 MACRO BSF PCLATH,1 ; SELECT ROM PAGE 1 ENDM ;---------------LCD TEXT OUTPUTER----------- STRING MOVWF STRNUM ; SAVE STRING NUMBER MOVLW b'11111111' ; NEEDS TO BE FF BEFORE ENTERING STRING MOVWF TABOFF ; SAVE IN CHR COUNTER MOVLW LCDRS ; SET TO DATA CALL LCD_TXT ; DO IT DOSTR PAGE1 ; SET PAGE MARKER CALL CALLSTR ; GET STRING CHARTER POINTED TO IN TABOFF PAGE0 ; RESET PAGE MARKER ; section above calls the text ect info and controls the page switching. MOVWF LCDCH ; SAVE CHAR ANDLW B'01111111' ; MASK END BIT (END OF STRING MARKER) CALL LCD_OUT BTFSS LCDCH,7 ; CHECK LAST GOTO DOSTR ; NOT FINISHED DO SOME MORE RETLW 0 ; CONTINUE PROGRAM ;-----------------AND IT FITS EXACTLY IN PAGE SPACE------ ;-----------------STRING CALLER-------------------------- ;-----------------MUST BE IN FIRST HALF OF PAGE DUE TO PC CONSTRAINTS ORG 200 ; the above statement ensures that the data starts at the start of a page boundary ; and includung the point macro must not be more than 256 bits long. LAST EQU b'10000000' CALLSTR MOVFW STRNUM ; GET STRING ADDWF PCL,1 ; WHICH STRING RETLW '0'+LAST RETLW '1'+LAST RETLW '2'+LAST RETLW '3'+LAST RETLW '4'+LAST RETLW '5'+LAST RETLW '6'+LAST RETLW '7'+LAST RETLW '8'+LAST RETLW '9'+LAST RETLW ' '+LAST GOTO MSG0 ; XYGAX Corp GOTO MSG1 ; 0117 955 4450 GOTO MSG2 ; CONTROL CENTRE GOTO MSG3 ; SYSTEM HEALTHY GOTO MSG4 ; GROUP GOTO MSG5 ; ZONE MSG0 POINT RETLW 'X' RETLW 'Y' RETLW 'G' RETLW 'A' RETLW 'X' RETLW ' ' RETLW 'C' RETLW 'o' RETLW 'r' RETLW 'p'+LAST MSG1 POINT RETLW '0' RETLW '1' RETLW '1' RETLW '7' RETLW ' ' RETLW '9' RETLW '5' RETLW '5' RETLW ' ' RETLW '4' RETLW '4' RETLW '5' RETLW '0'+LAST ...... ad infiniutum Content-ID: <0_1203_875559925@emout01.mail.aol.com.7745> Content-type: text/plain; name="CONCENA.ASM" ;Control Center written by S. M. Smith Dec '96 ;Designed to support 30 outputs and 30 inputs uses group features ;which are located in eerom ;designed for pic84 no WDT 4Mhz ceramic resonator LIST P=16C84 INCLUDE "P16C84.INC" __CONFIG _WDT_OFF & _XT_OSC TITLE "CONCEN.ASM" ;---------------PORT ASSIGNMENTS A IS ALWAYS OUTPUT-------- ;---------------B IS BIDIRECTIONAL AND HAS ASSESS TO------- ;---------------UP TO 64 IO LINES VIA 138------------------ CON EQU PORTA ; PORT A IS CONTROL DTA EQU PORTB ; PORT B IS DATA ;---------------138 LOCATION ASSIGNMENTS------------------ OUT1 EQU B'00000000' ; OUTPUTS 0-7 OUT2 EQU B'00000001' ; OUTPUTS 8-15 OUT3 EQU B'00000010' ; OUTPUTS 15-23 OUT4 EQU B'00000011' ; OUTPUTS 16-29 AND BUZZER AND LCD CONT INP1 EQU B'00000100' ; INPUTS 0-7 INP2 EQU B'00000101' ; INPUTS 8-15 INP3 EQU B'00000110' ; INPUTS 16-23 INP4 EQU B'00000111' ; INPUTS 24-29 AND TEST SW AND CONT SW ;---------------ODDS AND SODS BIT ASSIGNMENTS------------- LCDRS EQU B'11000000' ; LCD RS PIN (TEMP) NORMALLY '10000000' BUZ EQU B'01000000' ; BUZZER LOCATION CONOFF EQU B'00010000' ; CONTROL PORT OFF STATE ;---------------PORT A BIT 3 IS THE LCD ENABLE------------ ;---------------ACTIVE HIGH ALL 138 OUTPUTS--------------- ;---------------ARE ACTIVE LOW---------------------------- #DEFINE LCDEN CON,3 ; LCD ENABLE PIN NORMALLY LOW #DEFINE IOEN CON,4 ; IO ENABLE NORMALLY HIGH #DEFINE CARRY STATUS,0 ; DEFINE CARRY BIT #DEFINE ZERO STATUS,2 ; DEFINE ZERO BIT ;---------------MEMORY ASSIGNMENTS----------------------- INDIRECT EQU 00h MEMBAS EQU 0Ch ; MEMORY BOTTOM GP1 EQU MEMBAS ; GENERAL PURPOSE REGISTER STRNUM EQU GP1 +1 ; TEXT STRING NUMBER STORE CHPT EQU STRNUM +1 ; CHAR POINTER LCDCH EQU CHPT +1 ; LCD CHAR TABOFF EQU LCDCH+1 ; TABLE OFFSET INPUTS EQU MEMBAS +5 ; INPUTS TEMP STORE GP2 EQU MEMBAS +6 ; GENERAL PURPOSE REGISTER GP3 EQU MEMBAS +7 ; GENERAL PURPOSE REGISTER INREG1 EQU MEMBAS +8 ; INPUTS BANK 1 INREG2 EQU MEMBAS +9 ; INPUTS BANK 2 INREG3 EQU MEMBAS +.10 ; INPUTS BANK 3 INREG4 EQU MEMBAS +.11 ; INPUTS BANK 4 OUTREG1 EQU MEMBAS +.12 ; OUTPUTS BANK 1 OUTREG2 EQU MEMBAS +.13 ; OUTPUTS BANK 2 OUTREG3 EQU MEMBAS +.14 ; OUTPUTS BANK 3 OUTREG4 EQU MEMBAS +.15 ; OUTPUTS BANK 4 MAXINP EQU MEMBAS +.16 ; MAXIMUM INPUTS DONT CHANGE POS OF NEXT 8 MAXOUT EQU MEMBAS +.17 ; MAXIMUM OUTPUTS SPLIT EQU MEMBAS +.18 ; TEXT SPLIT ON INPUTS SPARE1 EQU MEMBAS +.19 ; DEFINED BUT NOT USED GROUP0 EQU MEMBAS +.20 ; GROUP STORE GROUP1 EQU MEMBAS +.21 ; GROUP STORE GROUP2 EQU MEMBAS +.22 ; GROUP STORE GROUP3 EQU MEMBAS +.23 ; GROUP STORE FOR EE INFO I/O EEOFFSET EQU MEMBAS +.24 ; EE OFFSET 0 CONSTANTS 4 8 12 16 GROUPS FLAG EQU MEMBAS +.25 ; MISC FLAGS GP4 EQU MEMBAS +.26 ; GENERAL PURPOSE REGISTER GP5 EQU MEMBAS +.27 ; GENERAL PURPOSE REGISTER GP6 EQU MEMBAS +.28 ; GENERAL PURPOSE REGISTER GP7 EQU MEMBAS +.29 ; GENERAL PURPOSE REGISTER TI1 EQU MEMBAS +.30 ; ERROR TIMER REGISTER TI2 EQU MEMBAS +.31 ; ERROR TIMER REGISTER TI3 EQU MEMBAS +.32 ; SECOND TIMER COUNTER ;---------------FLAG REGISTER---------------------- #DEFINE SEL FLAG,0 ; TEST PB (SEL) #DEFINE ACK FLAG,1 ; CONT PB (ACK) #DEFINE BEEP FLAG,2 ; BUZZER ACTIVE WHEN 1 #DEFINE FAULT FLAG,3 ; SET WHEN A FAULT IS ACTIVE #DEFINE OUT_ON FLAG,4 ; BIT IS 1 WHEN ON IS REQUIRED #DEFINE BIT_ON FLAG,5 ; BIT IS 1 WHEN G_DEF (TEMP STORE) ;---------------CONSTANT ASSIGNMENTS--------------- LEDON EQU .2 LEDOFF EQU .50 BZSHT EQU .2 LCDTIME EQU .3 MAX_G EQU .11 ; MAXIMUM GROUPS +1 ;------------------INCREMEMTS CHARTHER POINTER FOR TEXT STRING---------- POINT MACRO INCF TABOFF,1 MOVFW TABOFF ADDWF PCL,1 ENDM ;------------------REGISTER SWITCHING FOR PIC------------------------ BANK0 MACRO BCF STATUS,RP0 ; Select BANK 0 ENDM BANK1 MACRO BSF STATUS,RP0 ; Select BANK 1 ENDM ;------------------PAGE SWITCHING FOR 16C84---------------------------- PAGE0 MACRO BCF PCLATH,1 ; SELECT ROM PAGE 0 ENDM PAGE1 MACRO BSF PCLATH,1 ; SELECT ROM PAGE 1 ENDM ORG 0 GOTO INIT ;--------------------------------SUBROUTINES--------------------------------- ;--------------------------------LONG TIME TIMER---------------------------- LONG CLRF TMR0 ; CLEAR TO START MOVWF GP1 ; TEMP COUNT REG LONG2 BTFSC TMR0,7 ; 256 * 256 US = 64 MS GOTO JMP1 GOTO LONG2 ;LOOP UNTIL BIT SET JMP1 CLRF TMR0 ; YES SO CLR RTCC DECFSZ GP1,1 ; DECREASE TIL ZERO GOTO LONG2 ; ROUND THE LOOP RETLW 0 ; RETURN FROM SUB ;----------------SHORT TIMER (1US*2+3) PER CLK SHORT MOVWF GP1 ; TEMP COUNT REG SHORT1 DECFSZ GP1,1 ; DEC COUNT GOTO SHORT1 ; DO TIL FINISHED RETLW 0 ; RETURN FROM SUB ;---------------PORT B TO OUTPUT----------- BOUT BANK1 ; SET TO REGISTER BANK 1 MOVLW b'00000000' ; SET PORT STATE MOVWF DTA ; SET OUTPUTS BANK0 ; RESET REGISTER BANK 0 RETLW 0 ; EXIT ;--------------WRITE DATA ALREADY ON PORT TO LATCHES--------------- WRITE ADDLW CONOFF ; ADD THE OFF LOCATION TO PORT LOCATION MOVWF CON ; SET CONTROL PORT BCF IOEN ; CLOCK DATA OUT BSF IOEN ; RETURN TO NON SELECTED RETLW 0 ; EXIT ;---------------LCD TEXT OUTPUTER----------- STRING MOVWF STRNUM ; SAVE STRING NUMBER MOVLW b'11111111' ; NEEDS TO BE FF BEFORE ENTERING STRING MOVWF TABOFF ; SAVE IN CHR COUNTER MOVLW LCDRS ; SET TO DATA CALL LCD_TXT ; DO IT DOSTR PAGE1 ; SET PAGE MARKER CALL CALLSTR ; GET STRING CHARTER POINTED TO IN TABOFF PAGE0 ; RESET PAGE MARKER MOVWF LCDCH ; SAVE CHAR ANDLW B'01111111' ; MASK END BIT (END OF STRING MARKER) CALL LCD_OUT BTFSS LCDCH,7 ; CHECK LAST GOTO DOSTR ; NOT FINISHED DO SOME MORE RETLW 0 ; CONTINUE PROGRAM ;************* LCD CONTROL FUNCTIONS ****************************** ;--------------LCDRS----------------------------------------------- LCD_RS MOVLW BUZ ; LCD IN CONTROL MODE NO BUZ LCD_TXT MOVWF DTA ; INFO ON PORT MOVLW OUT4 ; SELECT ADDRESS CALL WRITE ; DO IT RETLW 0 ; EXIT ;---------------LCD PAUSE------------------ LCD_OUT MOVWF DTA ; PUT LCD CONTROL DATA ON BUS BSF LCDEN ; Lcd enable HIGH BCF LCDEN ; Lcd enable LOW ; SEND IT MOVLW .19 ; DELAY FOR LCD TO CATCH UP CALL SHORT ; DO TIME RETLW 0 ; EXIT ;--------------LCD CLEAR DISPLAY----------------------------------- LCDCLR CALL LCD_RS ; CONTROL MODE MOVLW 01h ; CLEAR DISPLAY CALL LCD_OUT ; SHORT TIME DELAY MOVLW LCDTIME ; TIME FOR LCD TO CATCH UP CALL LONG ; DO TIME RETLW 0 ; EXIT ;--------------LCD LINE 1 SELECT--------------------------------- LINE1 CALL LCD_RS ; CONTROL MODE MOVLW B'10000000' ; LINE 1 SET GOTO LCD_OUT ; SHORT TIME DELAY ;--------------LCD LINE 2 SELECT--------------------------------- LINE2 CALL LCD_RS ; CONTROL MODE MOVLW B'11000000' ; LINE 2 SET GOTO LCD_OUT ; SHORT TIME DELAY ;-------------LCD BACK 1 SPACE---------------------------------- BACK1 CALL LCD_RS ; CONTROL MODE MOVLW B'00010000' ; BACK ONE SPACE GOTO LCD_OUT ; SHORT TIME DELAY ;------------LCD LINE 2 POS 12---------------------------------- POS12 CALL LCD_RS ; CONTROL MODE MOVLW B'11001100' ; LINE 2 POS 12 GOTO LCD_OUT ; SHORT TIME DELAY ;------------LCD LINE 2 POS 8------------------------------------ POS8 CALL LCD_RS ; CONTROL MODE MOVLW B'11001000' ; LINE 2 POS 8 GOTO LCD_OUT ; SHORT TIME DELAY ;------------CUSOR BLINK----------------------------------------- BLINK CALL LCD_RS ; CONTROL MODE MOVLW B'00001110' ; CURSOR BLINK GOTO LCD_OUT ; SHORT TIME DELAY ;------------CURSOR NORMAL--------------------------------------- NO_BLINK CALL LCD_RS ; CONTROL MODE MOVLW B'00001100' ; CURSOR NORMAL GOTO LCD_OUT ; SHORT TIME DELAY ;-------------LCD INSERT SPACE W CONTAINS NUMBER OF------------- SPACE_0 MOVWF GP3 ; SAVE NUMBER OF SPACES SPACE_1 MOVLW .10 ; SPACE LOCATION CALL STRING ; GO DO IT DECFSZ GP3,F ; FINISHED GOTO SPACE_1 ; DO SOME MORE RETLW 0 ; EXIT ;************* END LCD CONTROL FUNCTIONS ************************ ;--------------BINARAY TO BCD CONVERTER------------------------- ;--------------W IS THE HEX TO BE CONVERTED--------------------- ;--------------GP3 IS THE LSD GP2 IS THE MSD-------------------- ;--------------THE TEXT IS DISPLAYED AND CURSOR RESET----------- BINBCD CLRF GP2 ; CLEAR THE MSD MOVWF GP3 ; SAVE BINARAY GT MOVLW .10 ; DECIMAL SUBTRACTION SUBWF GP3,W ; DEDUCT 10 BTFSS CARRY ; TEST CARRY GOTO BCDEX ; GOTO BCD EXIT MOVWF GP3 ; GET REMAINDER INCF GP2,F ; INCREASE MSD GOTO GT ; DO SOME MORE BCDEX MOVFW GP2 ; GET MSD CALL STRING ; DISPLAY MOVFW GP3 ; GET LSD CALL STRING ; DISPLAY CALL BACK1 ; RESET CURSOR CALL BACK1 ; RESET CURSOR RETLW 0 ; FINISHED EXIT ;-------------FUNCTION ROUTIENE TO SET UP ALL CONSTANTS---------- FUNCTION CALL LINE2 ; RESET LINE MOVLW .4 ; NUMBER OF SPACES CALL SPACE_0 ; DO IT MOVLW .11 ; DIFFERENCE BETWEEN MEMORY AND TXT STR SUBWF FSR,W ; W NOW CONTAINS TEXT STRING LOCATION CALL STRING ; DISPLAY TEXT FOR FUNCTION MOVLW .1 ; NUMBER OF SPACES CALL SPACE_0 ; DO SPACES MORE CLRF FLAG ; FINISHED WITH OLD BUTTON MOVFW INDIRECT ; GET DATA VALUE INCF W,W ; MAKE LOCATION 00 NON FUNCTIONAL CALL BINBCD ; CONVERT TO BCD AND DISPLAY MOVFW FSR ; GET FSR MOVWF GP4 ; SAVE FSR CALL CHK ; GET BUTTONS MOVFW GP4 ; GET OLD FSR MOVWF FSR ; RESTORE FSR BTFSC ACK ; CHECK ACK BUTTON RETLW 0 ; EXIT INCF INDIRECT,F ; INCREMENT DATA REG MOVLW .30 ; MAX CHANNELS SUBWF INDIRECT,W ; CHECK FOR OVERFLOW BTFSC ZERO ; TEST OVERFLOW CLRF INDIRECT ; RESET TO ZERO IF WAS 30 GOTO MORE ; DO MORE. ;----------------------------ZONE CONTROL SUBROUTIENE------------ Z_CONT CLRF GP4 ; USE GP4 AS MAIN COUNTER NEXT_Z CLRF FLAG ; FINISHED WITH BUTTONS MOVFW GP4 ; GET VALUE ADDLW .1 ; MAKE NO ZONE ZERO CALL BINBCD ; DISPLAY VALUE CALL CHK ; GET BUTTONS BTFSC ACK ; CHECK ACK BUTTON GOTO ON_OFF ; GOTO ON/OFF INCF GP4,F ; INCREMENT COUNTER MOVFW MAXOUT ; GET MAX CHANNELS SUBWF GP4,W ; SUBTRACT FROM COUNER BTFSC ZERO ; TEST FOR ZERO CLRF GP4 ; IF MAXOP THEN ITS ZERO GOTO NEXT_Z ; LOOP ;----------------------GROUP CONTROL SUBROUTIENE------------------- G_CONT MOVLW .1 ; MOVWF GP4 ; USE GP4 AS COUNTER NEXT_G CLRF FLAG ; FINISHED WITH BUTTONS MOVFW GP4 ; GET VALUE CALL BINBCD ; DISPLAY VALUE CALL CHK ; GET BUTTONS BTFSC ACK ; CHECK ACK BUTTON RETLW 0 ; EXIT INCF GP4,F ; INCREMENT COUNTER MOVLW MAX_G ; GET MAX GROUPS SUBWF GP4,W ; SUBTRACT FROM COUNER BTFSS ZERO ; TEST FOR ZERO GOTO NEXT_G ; LOOP GOTO G_CONT ; DO AGAIN USER DOSENT KNOW WHAT GROUP ;---------------PROCESS ON / OFF CONTROL OF ZONE / GROUP----------- ON_OFF CALL POS12 ; CURSOR POSITION 12 Z_ON BSF OUT_ON ; SET OUTPUT ON FLAG MOVLW .18 ; "ON" CALL STRING ; DISPLAY CALL POS12 ; SET CUSOR POSITION GOTO PBCHK ; CHECK PUSH BUTTONS Z_OFF BCF OUT_ON ; OUTPUTS TO OFF MOVLW .19 ; "OFF" CALL STRING ; DISPLAY CALL POS12 ; SET PUSH BUTTONS PBCHK CALL READ_IT ; GET BUTTONS BTFSC ACK ; ACK MUST BE CORRECT RETLW 0 ; EXIT BTFSS SEL ; SEL WRONG GOTO PBCHK ; WAIT FOR BUTTON BCF SEL ; FINISHED WITH SEL BTFSC OUT_ON ; TEST IF ON GOTO Z_OFF GOTO Z_ON ;---------------PROCESS IN / OUT OF GROUP SEGMENT----------------- Y_N BCF ACK ; CLEAR FLAG REG CALL POS12 ; CURSOR POSITION 12 GD_ON BSF BIT_ON ; SET OUTPUT ON FLAG MOVLW .30 ; "*" CALL STRING ; DISPLAY CALL POS12 ; SET CUSOR POSITION GOTO GD_PB ; CHECK PUSH BUTTONS GD_OFF BCF BIT_ON ; OUTPUTS TO OFF MOVLW .10 ; " " CALL STRING ; DISPLAY CALL POS12 ; SET PUSH BUTTONS GD_PB CALL READ_IT ; GET BUTTONS BTFSC ACK ; ACK MUST BE CORRECT RETLW 0 ; EXIT BTFSS SEL ; SEL WRONG GOTO GD_PB ; WAIT FOR BUTTON BCF SEL ; FINISHED WITH SEL BTFSC BIT_ON ; TEST IF ON GOTO GD_OFF GOTO GD_ON ;----------------------SYSTEM FAULT ANNOUNCEMENT----------------- SYS_FAULT BSF FAULT ; INDICATE FAULTS ARE ACTIVE CALL LINE2 ; SET CURSOR MOVFW GP4 ; GET ZONE / CIRCUIT NUMBER SUBWF SPLIT,W ; DEDUCT THE SPLIT (CONSTANT) BTFSC CARRY ; TEST FOR CIRCUIT GOTO D_ZONE ; DISPLAY ZONE MOVFW SPLIT ; GET CONSTANT SUBWF GP4,W ; SUBTRACT FROM CIRCUIT N MOVWF GP2 ; TEMP STORE FOR CIRCUIT N MOVLW .17 ; "CIRCUIT" CALL STRING ; DISPLAY GOTO D_FLT ; GOTO DISPLAY "FAULT" D_ZONE MOVFW GP4 ; INPUT NUMBER MOVWF GP2 ; TEMP STORE FOR ZONE N MOVLW .3 ; NUBER OF SPACES CALL SPACE_0 ; DO SPACES MOVLW .16 ; "ZONE" CALL STRING ; DISPLAY D_FLT MOVLW .20 ; "FAULT" CALL STRING ; DISPLAY MOVFW GP2 ; RESTORE N CALL BINBCD ; DO NUMBERS PAGE1 ; PAGE SWITCH FOR VECTOR SUB CALL DO_BEEP ; DO THE BEEP ROUTIENE PAGE0 ; RESET PAGE MARKER CALL LONG ; W RETURNS WITH TEXT DISPLAY TIME RETLW 0 ; EXIT ;-------------READ PUSH BUTTONS AND DEBOUNCE------------ READ_IT PAGE1 ; SET PAGE BITS BCF ACK ; CLEAR OLD BUTTON BCF SEL ; CLEAR OLD BUTTON CALL READ ; GET BUTTONS PAGE0 ; RESET PAGE MARKER MOVLW LEDON ; DEBOUNCE TIME CALL LONG ; DO TIME RETLW 0 ; EXIT ;-------------PUSH BUTTON SELECTION CHECKER------------- CHK CLRF TI1 ; CLEAR COUNTER CHK1 INCF TI1 ; INCREMENT COUNTER BTFSC ZERO ; CHECK FOR OVERFLOW GOTO MAIN ; DIRTY EXIT CALL READ_IT ; GET BUTTONS SUBWF FLAG,W ; -0 SETS Z FLAG BTFSC ZERO ; CHECK FOR BUTTON GOTO CHK1 ; WAIT FOR BUTTON RETLW 0 ; EXIT ;--------------GROUP REGISTER SETUP--------------------- G_SET BCF CARRY ; CLEAR CARRY OFF NORMAL BTFSC BIT_ON ; TEST TO SEE IF BIT NEEDS TO BE SET BSF CARRY ; IF REQUIRED SET CARRY MOVFW GP7 ; GET FSR VALUE MOVWF FSR ; RESTORE FSR RRF INDIRECT,F ; ROLL GROUP N THROU CARRY DECFSZ GP5,F ; INCREMENT BYTE INDEX RETLW 0 ; EXIT INCF GP7,F ; GOTO NEXT GROUP MOVLW .8 ; NUMBER OF BITS MOVWF GP5 ; RESET COUNT 8 MARKER RETLW 0 ; EXIT ;-------------INITALISATION----------------------------- ;------------RTCC AND OUTPUT SETUP---------------------- ORG 100 INIT CLRF PCLATH ; RESET PAGE MARKER CLRF EEOFFSET ; CLEAR EE OFFSET CLRF FLAG ; CLEAR FLAG REGISTER MOVLW CONOFF ; SET CONTROL TO OFF MOVWF CON ; DO IT BANK1 ; REGISTER SET 1 MOVLW B'00000111' ; RTCC PRESCALER /256 MOVWF OPTION_REG ; 256 US PER COUNT MOVLW b'00000000' ; ALL OUTPUTS MOVWF CON ; SET UP CONTROL PORT BANK0 ; RESET REGISTER BANK MOVWF OUTREG1 ; OUT1 MOVWF OUTREG2 ; OUT2 MOVWF OUTREG3 ; OUT3 IORLW B'11000000' ; MASK BUZZER AND LCDRS MOVWF OUTREG4 ; OUT4 MOVLW .5 ; LCD POWER ON SETTLE TIME CALL LONG ; TIMER RUN ;------------------SETUP AND RESTORE SYSTEM CONSTANTS RETRO PAGE1 ; VECTOR SUB IN PAGE 1 CALL READ ; CHECK STATUS OF BUTTONS CALL WRITE_1 ; WRITE ALL INFO CALL EEREAD ; LOAD CONSTANTS PAGE0 ; RESTORE PAGE BIT MOVFW GROUP0 ; GET MAXINP MOVWF MAXINP ; SAVE CONSTANT INCF MAXINP,F ; NEEDED FOR COUNTERS FROM 1-N NOT 0-N MOVFW GROUP1 ; GET MAXOUT MOVWF MAXOUT ; SAVE CONSTANT INCF MAXOUT,F ; NEEDED FOR COUNTERS FROM 1-N NOT 0-N MOVFW GROUP2 ; GET SPLIT MOVWF SPLIT ; SAVE CONSTANT ;------------------LCD SETUP ROUTINE--------------- CALL LCD_RS ; LCD IN CONTROL MODE MOVLW 38h ; LCD RESET CALL LCD_OUT ; DO INSTRUCTION MOVLW 06h ; DISPLAY DIR RIGHT CALL LCD_OUT ; DO INSTRUCTION MOVLW 0Ch ; DISPLAY ON AND CURSER SET CALL LCD_OUT ; DO INSTRUCTION ;---------------DISPLAY ANNOUNCEMENTS------------------- CALL LCDCLR ; CLEAR DISPLAY MOVLW .2 ; NUMBER OF SPACES CALL SPACE_0 ; DO SPACE MOVLW .11 ; TEXT STRING MANUF CALL STRING ; DISPLAY MANUF CALL LINE2 ; LINE SWITCH MOVLW .1 ; NUMBER OF SPACES CALL SPACE_0 ; DO SPACE MOVLW .12 ; TEXT STRING TEL NO CALL STRING ; DISPLAY TEL NUMBER MOVLW LEDOFF ; TIME DELAY CALL LONG ; DO TIME CALL LCDCLR ; CLEAR DISPLAY MOVLW .13 ; TEXT STRING FUNCTION CALL STRING ; DISPLAY FUNCTION CALL LINE2 ; LINE SWITCH MOVLW .4 ; NUMBER OF SPACES CALL SPACE_0 ; DO IT MOVLW .28 ; LOADING CALL STRING ; DO DISPLAY MOVLW LEDOFF ; TIME CALL LONG ; DO TIME BTFSS SEL ; TEST SEL GOTO MAIN ; GOTO MAIN PROGRAM ;********************************************************** SETUP MENU **************** SETUP CLRF FLAG ; CLEAR FLAG REG CALL LCDCLR ; CLEAR DISPLAY MOVLW .3 ; NUMBER OF SPACES CALL SPACE_0 ; DO IT MOVLW .26 ; SETUP MENU CALL STRING ; DISPLAY INFO MOVLW MEMBAS+.20 ; LOCATION OF MEMORY LOCATION MOVWF FSR ; DATA POINTER LOADED SETUP_MAXIP CALL FUNCTION ; DO FUNCTION FOR MAX IP CLRF FLAG ; FINISHED WITH BUTTON INCF FSR,F ; NEXT SEGMENT SETUP_MAXOP CALL FUNCTION ; DO FUNCTION FOR MAX OP CLRF FLAG ; FINISHED WITH BUTTON INCF FSR,F ; NEXT SEGMENT SETUP_SPLIT ;-------------------------THE SPLIT NUMBER IS THE FIRST CIRCUIT FAULT----- CALL FUNCTION ; DO FUNCTION FOR SPLIT CLRF FLAG ; FINISHED WITH BUTTON INCF FSR,F ; NEXT SEGMENT SETUP_SPARE CALL FUNCTION ; DO FUNCTION FOR SPARE SETUP_EEWRITE CALL LINE2 ; RESET MARKER TO START OF LINE 2 MOVLW .5 ; NUMBER OF SPACES CALL SPACE_0 ; DO IT MOVLW .27 ; STRING SAVING CALL STRING ; DO IT MOVLW .4 ; MASK GARBAGE CALL SPACE_0 ; DO IT MOVLW 0 ; FSR OFFSET MOVWF EEOFFSET ; SET FOR LOCATION 0 PAGE1 ; VECTOR SUB ON PAGE1 CALL EEWRITE ; SAVE INFO PAGE0 ; RETURN TO PAGE 0 MOVLW LEDOFF ; LOAD TIME DELAY CALL LONG ; DO TIME GOTO RETRO ; GO RESTORE CONSTANTS ;*************************************************************** END SETUP MENU ******* ;---------------------Main program loop--------------------------- MAIN CALL LCDCLR ; CLEAR LCD MOVLW .13 ; TEXT FUNCTION CALL STRING ; DISPLAY TEXT MAIN_1 CALL LINE2 ; RESET TO LINE 2 MOVLW .1 ; NUMBER OF SPACES CALL SPACE_0 ; DO SPACES MOVLW .14 ; MESSAGE "SYSTEM HEALTHY" BTFSS FAULT ; CHECK FOR FAULTS CALL STRING ; DO DISPLAY MOVLW .3 ; NUMBER OF SPACES CALL SPACE_0 ; DO SPACES BCF FAULT ; CLEAR FLAG BSF BEEP ; SET BEEPS TO ON EXIT_2 ;----------SECTION TO READ INPUTS AND DECIPHER-------------- MAIN_2 BCF FAULT ; CLEAR FAULT FLAG CALL READ_IT ; GET INPUTS AND SET FLAGS BTFSC ACK ; TEST ACK BCF BEEP ; ACK THEN STOP BEEP MOVLW MEMBAS+.8 ; LOCATION OF INREG1 MOVWF FSR ; SETUP INDIRECT ACCESS CLRF GP4 ; CLEAR COUNT REGISTER INTST CLRF GP5 ; CLEAR COUNT 8 REG BSF CARRY ; SET CARRY FLAG INTST1 INCF GP4,F ; NUMBER OF TIMES ROUND LOOP INCF GP5,F ; INCREMENT BYTE INDEX RRF INDIRECT,F ; ROLL INREG 1 THROU CARRY BTFSS CARRY ; TEST FOR SIGNAL ******THIS NEEDS REVERSING ****** CALL SYS_FAULT ; GO AND PROCESS DISPLAY BTFSC SEL ; *** CHECK SEL BUTTON GOTO MAIN_MENU ; *** YES THEN USER WANTS MENU MOVFW GP4 ; GET COUNT REGISTER SUBWF MAXINP,W ; SUBTRACT FROM MAX INPUTS (CONSTANT) BTFSC ZERO ; IF ZERO MAX COUNT REACHED GOTO EXIT ; EXIT BTFSS GP5,3 ; CHECK GP5=8 GOTO INTST1 ; THEN DO AGAIN INCF FSR,F ; CKECK NEXT REGISTER GOTO INTST ; DO SOME MORE EXIT BTFSC SEL ; CHECK SEL BUTTON GOTO MAIN_MENU ; YES THEN USER WANTS MENU BTFSS FAULT ; CHECK FAULT FLAG GOTO MAIN_1 ; NO FAULT GOTO MAIN_2 ; FAULT THEN CHECK AND DISPLAY SOME MORE ;-----------------MENU SECTION TO DEFINE OUTPUTS AND GROUPS-------- MAIN_MENU CALL LCDCLR ; CLEAR DISPLAY MOVLW .3 ; NUMBER OF SPACES CALL SPACE_0 ; DO SPACES MOVLW .25 ; MAIN MENU CALL STRING ; DISPLAY CHK_0 CALL LINE2 ; GOTO LINE 2 MOVLW .31 ; TEXT "EXIT" CALL STRING ; DO TEXT CLRF TI1 ; CLEAR COUNTER CHK_1 CALL CHK1 ; GET BUTTONS BTFSC ACK ; IS SEL DOWN GOTO MAIN ; DO THE ZONE THING BTFSS SEL ; PINKY ON SEL GOTO CHK_1 ; NO DO MORE BUTTONS CALL LINE2 ; RESET TO LINE 2 MOVLW .16 ; TEXT "ZONE" CALL STRING ; DO TEXT CLRF TI1 ; CLEAR COUNTER CHK_2 CALL CHK1 ; GET BUTTONS BTFSC ACK ; IS SEL DOWN GOTO Z1 ; DO THE ZONE THING BTFSS SEL ; PINKY ON SEL GOTO CHK_2 ; NO DO MORE BUTTONS CALL LINE2 ; RESET TO LINE 2 MOVLW .15 ; TEXT "GROUP" CALL STRING ; DO TEXT CLRF TI1 ; CLEAR COUNTER CHK_3 CALL CHK1 ; GET BUTTONS BTFSC ACK ; IS SEL DOWN GOTO G1 ; DO THE GROUP THING BTFSS SEL ; PINKY ON SEL GOTO CHK_3 ; NO DO MORE BUTTONS MOVLW .29 ; TEXT "DEF" CALL STRING ; DO TEXT CLRF TI1 ; CLEAR COUNTER CHK_4 CALL CHK1 ; GET BUTTONS BTFSC ACK ; IS SEL DOWN GOTO D1 ; DO THE DEFINE THING BTFSS SEL ; PINKY ON SEL GOTO CHK_4 ; NO DO MORE BUTTONS GOTO MAIN_MENU ; NO MORE MENU BITS Z1 CALL Z_CONT ; ZONE CONTROL INFO IN GP4 FLAG ON/OFF PAGE1 ; VECTOR SUB CALL CONVERT ; CONVERT GP4 INTO POSITION IN GROUP 0-3 GOTO Z2 ; DO THE REST OF THE FUNCTION G1 CALL G_CONT ; GROUP CONTROL GP4 CONTAINS GROUP NUMBER CALL ON_OFF ; SET STATUS PAGE1 ; VECTOR SUB CALL MULT_4 ; CALCLUTE EE ADDRESS RESULT EEOFFSET CALL EEREAD ; READ GROUP INFO Z2 CALL DO_OUT ; SORT OUT OUTREG 1-4 CALL WRITE_1 ; DO THE GROUP OUT PAGE0 GOTO MAIN D1 CALL G_CONT ; SORT OUT WHICH GROUP TO DEFINE GP4 CONTAINS GROUP NO CALL LCDCLR ; CLEAR LCD MOVLW .2 ; NO OF SPACES CALL SPACE_0 ; DO SPACES MOVLW .15 ; GET GROUP CALL STRING ; DISPLAY MOVLW .29 ; GET DEF CALL STRING ; DISPLAY MOVFW GP4 ; GET GROUP NUMBER CALL BINBCD ; DISPLAY CALL LINE2 ; SET CURSOR TO LINE 2 MOVLW .3 ; NUMBER OF SPACES CALL SPACE_0 ; DO SPACES MOVLW .16 ; TEXT 'ZONE' CALL STRING ; DO TEXT CALL BLINK ; FLASH CURSOR HERE ;-------------GROUP ZONE DEFINITION--------------------- ;-------------.10 IS SPACE .30 IS * DONT TOUCH GP4------ ;-------------POS 8 IS FOR BINBCD AND POS 12 IS FOR */_ MOVLW MEMBAS+.20 ; LOCATION OF GROUP0 MOVWF GP7 ; SETUP INDIRECT ACCESS GP7 TEMP FSR STORE MOVLW .8 ; NUMBER OF BITS MOVWF GP5 ; BIT COUNTER CLRF GP6 ; USE GP6 AS MAIN COUNTER NEXT_GD CLRF FLAG ; FINISHED WITH BUTTONS CALL POS8 ; MAKE DISPLAY POSITION MOVFW GP6 ; GET VALUE ADDLW .1 ; MAKE NO ZONE ZERO CALL BINBCD ; DISPLAY VALUE CALL CHK BTFSC ACK ; CHECK ACK BUTTON CALL Y_N ; CHECK IN / OUT OF GROUP MOVLW .10 ; " " CALL STRING ; DISPLAY CALL POS12 ; SET TEXT LOCATION CALL G_SET ; SET GROUP0-3 REGISTERS INCF GP6,F ; INCREMENT COUNTER MOVFW MAXOUT ; GET MAX CHANNELS SUBWF GP6,W ; SUBTRACT FROM COUNER BTFSC ZERO ; TEST FOR ZERO GOTO GD_EX ; FINISHED THEN EXIT GOTO NEXT_GD ; LOOP GD_EX BTFSC GP5,3 ; ARE WE AT START OF CHIP GOTO GD_EX1 ; NOW EXIT CALL G_SET ; ROLL TILL FINISHED GOTO GD_EX ; NO DO SOME MORE GD_EX1 PAGE1 ; SET TO PAGE1 FOR VECTOR SUBS CALL MULT_4 ; SET UP EEPROM ADDRESS FROM G_CONT CALL EEWRITE ; GROUP0 TO GROUP N NOW CONTAIN GROUP INFO PAGE0 ; RESET PAGE MARKER CALL NO_BLINK ; DONT FLASH CURSOR NOW GOTO MAIN ;-----------------DONT TOUCH IT WORKS-------------------- ;-----------------AND IT FITS EXACTLY IN PAGE SPACE------ ;-----------------STRING CALLER-------------------------- ;-----------------MUST BE IN FIRST HALF OF PAGE DUE TO PC CONSTRAINTS ORG 200 LAST EQU b'10000000' CALLSTR MOVFW STRNUM ; GET STRING ADDWF PCL,1 ; WHICH STRING RETLW '0'+LAST RETLW '1'+LAST RETLW '2'+LAST RETLW '3'+LAST RETLW '4'+LAST RETLW '5'+LAST RETLW '6'+LAST RETLW '7'+LAST RETLW '8'+LAST RETLW '9'+LAST RETLW ' '+LAST GOTO MSG0 ; XYGAX Corp GOTO MSG1 ; 0117 955 4450 GOTO MSG2 ; CONTROL CENTRE GOTO MSG3 ; SYSTEM HEALTHY GOTO MSG4 ; GROUP GOTO MSG5 ; ZONE GOTO MSG6 ; CIRCUIT GOTO MSG7 ; ON GOTO MSG8 ; OFF GOTO MSG9 ; FAULT GOTO MSG10 ; MAX IP GOTO MSG11 ; MAX OP GOTO MSG12 ; SPLIT GOTO MSG13 ; SPARE GOTO MSG14 ; MAIN MENU GOTO MSG15 ; SETUP MENU GOTO MSG16 ; SAVING GOTO MSG17 ; LOADING GOTO MSG18 ; DEF RETLW '*'+LAST GOTO MSG19 ; EXIT MSG0 POINT RETLW 'X' RETLW 'Y' RETLW 'G' RETLW 'A' RETLW 'X' RETLW ' ' RETLW 'C' RETLW 'o' RETLW 'r' RETLW 'p'+LAST MSG1 POINT RETLW '0' RETLW '1' RETLW '1' RETLW '7' RETLW ' ' RETLW '9' RETLW '7' RETLW '2' RETLW ' ' RETLW '3' RETLW '8' RETLW '8' RETLW '0'+LAST MSG2 POINT RETLW ' ' RETLW 'C' RETLW 'O' RETLW 'N' RETLW 'T' RETLW 'R' RETLW 'O' RETLW 'L' RETLW ' ' RETLW 'C' RETLW 'E' RETLW 'N' RETLW 'T' RETLW 'E' RETLW 'R'+LAST MSG3 POINT RETLW 'S' RETLW 'Y' RETLW 'S' RETLW 'T' RETLW 'E' RETLW 'M' RETLW ' ' RETLW 'H' RETLW 'E' RETLW 'A' RETLW 'L' RETLW 'T' RETLW 'H' RETLW 'Y'+LAST MSG4 POINT RETLW 'G' RETLW 'R' RETLW 'O' RETLW 'U' RETLW 'P' RETLW ' '+LAST MSG5 POINT RETLW 'Z' RETLW 'O' RETLW 'N' RETLW 'E' RETLW ' '+LAST MSG6 POINT RETLW 'C' RETLW 'I' RETLW 'R' RETLW 'C' RETLW 'U' RETLW 'I' RETLW 'T' RETLW ' '+LAST MSG7 POINT RETLW 'O' RETLW 'N' RETLW ' '+LAST MSG8 POINT RETLW 'O' RETLW 'F' RETLW 'F'+LAST MSG9 POINT RETLW 'F' RETLW 'A' RETLW 'U' RETLW 'L' RETLW 'T' RETLW ' '+LAST MSG10 POINT RETLW 'M' RETLW 'A' RETLW 'X' RETLW ' ' RETLW 'I' RETLW 'P'+LAST MSG11 POINT RETLW 'M' RETLW 'A' RETLW 'X' RETLW ' ' RETLW 'O' RETLW 'P'+LAST MSG12 POINT RETLW 'S' RETLW 'P' RETLW 'L' RETLW 'I' RETLW 'T' RETLW ' '+LAST MSG13 POINT RETLW 'S' RETLW 'P' RETLW 'A' RETLW 'R' RETLW 'E' RETLW ' '+LAST MSG14 POINT RETLW 'M' RETLW 'A' RETLW 'I' RETLW 'N' RETLW ' ' RETLW 'M' RETLW 'E' RETLW 'N' RETLW 'U'+LAST MSG15 POINT RETLW 'S' RETLW 'E' RETLW 'T' RETLW 'U' RETLW 'P' RETLW ' ' RETLW 'M' RETLW 'E' RETLW 'N' RETLW 'U'+LAST MSG16 POINT RETLW 'S' RETLW 'A' RETLW 'V' RETLW 'I' RETLW 'N' RETLW 'G'+LAST MSG17 POINT RETLW 'L' RETLW 'O' RETLW 'A' RETLW 'D' RETLW 'I' RETLW 'N' RETLW 'G'+LAST MSG18 POINT RETLW 'D' RETLW 'E' RETLW 'F' RETLW ' '+LAST MSG19 POINT RETLW 'E' RETLW 'X' RETLW 'I' RETLW 'T'+LAST ORG 2F4h ;--------------------------VECTOR SUB JUMP TABLE------------- ;--------------------------MUST BE IN FIRST HALF OF PAGE DUE TO PC CONSTRAINTS EEWRITE GOTO EEWRITE_1 EEREAD GOTO EEREAD_1 READ GOTO READ_1 WRITE_1 GOTO WRITE_2 DO_BEEP GOTO BEEP_1 DO_OUT GOTO OUTPUT_HANDLE CONVERT GOTO CONVERT_1 MULT_4 GOTO MULT ORG 300h ;--------------EE WRITE WRITES THE FOUR BYTES GROUP1-4----------- ;--------------AT OFFSET IN EEOFFSET----------------------------- ;--------------RAM BASE ADDRESS IS MEMBAS +20-------------------- EEWRITE_1 MOVLW .04 ; MAXIMUM NUMBER OF BYTES MOVWF GP1 ; COUNTER MOVLW MEMBAS+.20 ; MEM BASE ADDRESS MOVWF FSR ; STORE IN FILE SELECT REG MOVF EEOFFSET,W ; GET EE ADDRESS MOVWF EEADR ; SAVE IN EE ADDRESS EELOOP2 MOVF INDIRECT,W ; GET INFO AT LOCATION POINTED TO BY FSR MOVWF EEDATA ; PUT DATA IN EE OUT REG BANK1 ; SWITCH REGISTER BANK BSF EECON1,WREN ; WRITE ENABLE MOVLW 55h ; FROM DATA BOOK MOVWF EECON2 ; SEQUENCE TO WRITE EEROM MOVLW 0AAh MOVWF EECON2 BSF EECON1,WR ; WRITE THE DATA EELOOP BTFSC EECON1,WR ; WAIT FOR FINISH GOTO EELOOP ; DO MORE WAITING BANK0 ; SELECT BANK 0 INCF FSR,F ; NEXT BYTE INCF EEADR,F ; NEXT LOCATION DECFSZ GP1,F ; ONE LESS TO DO GOTO EELOOP2 ; DO NEXT RETLW 0 ; EXIT ;--------------EE READ WRITES THE FOUR BYTES GROUP1-4------------ ;--------------AT OFFSET IN EEOFFSET----------------------------- ;--------------RAM BASE ADDRESS IS MEMBAS +20-------------------- EEREAD_1 MOVLW .04 ; MAXIMUM NUMBER OF BYTES MOVWF GP1 ; COUNTER MOVLW MEMBAS+.20 ; MEM BASE ADDRESS MOVWF FSR ; STORE IN FILE SELECT REG MOVF EEOFFSET,W ; GET EE ADDRESS MOVWF EEADR ; SAVE IN EE ADDRESS EER2 BANK1 ; SWITCH REGISTER BANK BSF EECON1,RD ; SET READ BIT EER1 BTFSC EECON1,RD ; TEST IF FINISHED GOTO EER1 ; LOOP TIL TIS BANK0 ; REGISTER BANK 0 MOVF EEDATA,W ; DATA NOW IN W MOVWF INDIRECT ; SAVE IN GROUP INCF FSR,F ; NEXT BYTE INCF EEADR,F ; NEXT LOCATION DECFSZ GP1,F ; ONE LESS TO DO GOTO EER2 ; DO NEXT RETLW 0 ; EXIT ;--------------READ DATA ON INPUTS TO FILE LOCATION---------------- ;--------------DATA ON INPUTS 1-4 (0-32) ARE SAVED IN INREG 1-4 READ_1 MOVLW .4 ; NUMBER OF LOCATIONS MOVWF GP1 ; SAVE IN TEMP STORE READ_2 MOVFW GP1 ; GET COUNTER ADDLW CONOFF+3 ; ADD THE OFF LOCATION TO PORT LOCATION MOVWF CON ; SET CONTROL PORT CLRF DTA ; CLEAR GARBAGE MOVLW B'11111111' ; PORT INPUTS BANK1 ; REGISTER BANK 1 MOVWF DTA ; SET B AS INPUTS BANK0 ; REGISTER BANK 0 MOVFW GP1 ; GET COUNTER ADDLW .7+MEMBAS ; ADD OFFSET MOVWF FSR ; SAVE IN INDIRECT ADDRESS BCF IOEN ; ENABLE PORT MOVF DTA,W ; INPUTS INTO W MOVWF INDIRECT ; SAVE IN TEMP STORE BSF IOEN ; DISABLE PORT CLRF DTA ; CLEAR GARBAGE MOVLW B'00000000' ; OUTPUTS BANK1 ; REGISTER BANK 1 MOVWF DTA ; SET B AS OUTPUTS BANK0 ; REGISTER BANK 0 DECFSZ GP1,F ; TEST FINISHED GOTO READ_2 ; DO NEXT BTFSS INREG4,6 ; TEST TEST BSF SEL ; SET FLAG SEL BTFSS INREG4,7 ; TEST CONT BSF ACK ; SET FLAG ACK BTFSS INREG4,6 ; TEST BUTTON NOT PRESSED GOTO READ_1 ; BUTTON DOWN DO TIL RELEASED BTFSS INREG4,7 ; TEST BUTTON NOT PRESSED GOTO READ_1 ; BUTTON DOWN DO TIL RELEASED RETLW 0 ; RETURN TO PROGRAM ;-------------------DATA IN OUTREG 1 TO OUTREG 4 TO PORT-------------------- WRITE_2 MOVLW .4 ; NUMBER OF LOCATIONS MOVWF GP1 ; SAVE IN TEMP STORE WRITE_3 MOVFW GP1 ; GET COUNTER ADDLW CONOFF-1 ; ADD THE OFF LOCATION TO PORT LOCATION .4-3=-1 MOVWF CON ; SET CONTROL PORT MOVFW GP1 ; GET COUNTER ADDLW .11+MEMBAS ; ADD OFFSET MOVWF FSR ; SAVE IN INDIRECT ADDRESS MOVFW INDIRECT ; GET PORT INFO MOVWF DTA ; PUT ON BUS NOP ; TIME TO SETTLE BCF IOEN ; ENABLE LATCH NOP ; TIME TO SETTLE BSF IOEN ; DISABLE LATCH DECFSZ GP1,F ; TEST FINISHED GOTO WRITE_3 ; DO NEXT RETLW 0 ;--------------------BUZZER HANDLER------------------------------- BEEP_1 MOVLW CONOFF+7 ; LOCATION OF THE BUTTONS MOVWF CON ; SET CONTROL PORT CLRF DTA ; CLEAR GARBAGE MOVLW B'11111111' ; PORT INPUTS BANK1 ; REGISTER BANK 1 MOVWF DTA ; SET B AS INPUTS BANK0 ; REGISTER BANK 0 BCF IOEN ; ENABLE PORT BTFSS DTA,7 ; TEST PUSH BUTTON BCF BEEP ; LOW ON ACK PB CLEAR BEEP FLAG BTFSS DTA,6 ; CHECK SEL LINE BSF SEL ; SET SEL BSF IOEN ; DISABLE PORT CLRF DTA ; CLEAR GARBAGE MOVLW B'00000000' ; OUTPUTS BANK1 ; REGISTER BANK 1 MOVWF DTA ; SET B AS OUTPUTS BANK0 ; REGISTER BANK 0 BTFSS BEEP ; TEST FOR BUZZER REQUIRED RETLW .50 ; NO BUZ REQUIRED EXIT TIME PERIOD MOVLW B'00000000' ; GET BUZZER LOCATION MOVWF DTA ; PUT ON BUS MOVLW CONOFF+3 ; ADD THE OFF LOCATION TO PORT LOCATION MOVWF CON ; SET CONTROL PORT BCF IOEN ; CLOCK DATA OUT BSF IOEN ; RETURN TO NON SELECTED MOVLW .4 ; TIME PERIOD CLRF TMR0 ; CLEAR TO START MOVWF TI3 ; TEMP COUNT REG LONGH MOVLW CONOFF+7 ; LOCATION OF THE BUTTONS MOVWF CON ; SET CONTROL PORT CLRF DTA ; CLEAR GARBAGE MOVLW B'11111111' ; PORT INPUTS BANK1 ; REGISTER BANK 1 MOVWF DTA ; SET B AS INPUTS BANK0 ; REGISTER BANK 0 BCF IOEN ; ENABLE PORT BTFSS DTA,7 ; TEST PUSH BUTTON BCF BEEP ; LOW ON ACK PB CLEAR BEEP FLAG BTFSS DTA,6 ; CHECK SEL LINE BSF SEL ; SET SEL BSF IOEN ; DISABLE PORT CLRF DTA ; CLEAR GARBAGE MOVLW B'00000000' ; OUTPUTS BANK1 ; REGISTER BANK 1 MOVWF DTA ; SET B AS OUTPUTS BANK0 ; REGISTER BANK 0 BTFSC TMR0,7 ; 256 * 256 US = 64 MS GOTO JMPH ; TMR OVERFLOW GOTO NEXT BIT GOTO LONGH ; LOOP UNTIL BIT SET JMPH CLRF TMR0 ; YES SO CLR RTCC DECFSZ TI3,1 ; DECREASE TIL ZERO GOTO LONGH ; ROUND THE LOOP MOVLW B'01000000' ; BUZZER OFF MOVWF DTA ; PUT ON BUS MOVLW CONOFF+3 ; ADD THE OFF LOCATION TO PORT LOCATION MOVWF CON ; SET CONTROL PORT BCF IOEN ; CLOCK DATA OUT BSF IOEN ; RETURN TO NON SELECTED RETLW .25 ; BUZZER REQUIRED EXIT TIME PERIOD ;----------------------OUTPUT HANDLER--------------------------------------- OUTPUT_HANDLE ;---------------------- OUTPUTS OFF----------------------------------------- BTFSC OUT_ON ; TEST FOR CONDITION REQUIRED GOTO OUT_ON_1 ; MUST BE TURN OUTPUTS OFF MOVFW OUTREG1 ; GET OLD STATUS XORWF GROUP0,W ; FIX NEW STATUS MOVWF OUTREG1 ; RESTORE FOR SENDING MOVFW OUTREG2 ; GET OLD STATUS XORWF GROUP1,W ; FIX NEW STATUS MOVWF OUTREG2 ; RESTORE FOR SENDING MOVFW OUTREG3 ; GET OLD STATUS XORWF GROUP2,W ; FIX NEW STATUS MOVWF OUTREG3 ; RESTORE FOR SENDING MOVWF OUTREG4 ; GET OLD STATUS XORWF GROUP3,W ; FIX NEW STATUS IORLW B'11000000' ; MASK TWO TOP BITS (BUZZER AND LCDRS) MOVWF OUTREG4 ; RESTORE FOR SENDING RETLW 0 ; EXIT ;---------------------- OUTPUTS ON------------------------------------------ OUT_ON_1 MOVFW OUTREG1 ; GET OLD STATUS IORWF GROUP0,W ; FIX NEW STATUS MOVWF OUTREG1 ; RESTORE FOR SENDING MOVFW OUTREG2 ; GET OLD STATUS IORWF GROUP1,W ; FIX NEW STATUS MOVWF OUTREG2 ; RESTORE FOR SENDING MOVFW OUTREG3 ; GET OLD STATUS IORWF GROUP2,W ; FIX NEW STATUS MOVWF OUTREG3 ; RESTORE FOR SENDING MOVWF OUTREG4 ; GET OLD STATUS IORWF GROUP3,W ; FIX NEW STATUS IORLW B'11000000' ; MASK TOP TWO BITS (BUZZER AND LCDRS) MOVWF OUTREG4 ; RESTORE FOR SENDING RETLW 0 ; EXIT ;-------------------------CONVERT------------------------------------ ;----------------CONVERTS GP4 REG INTO BIT POSITION IN GROUP 0-3----- CONVERT_1 CLRF GROUP0 ; CLEAR GARBAGE CLRF GROUP1 ; CLEAR GARBAGE CLRF GROUP2 ; CLEAR GARBAGE CLRF GROUP3 ; CLEAR GARBAGE MOVLW .4 ; NUMBER OF GROUP REGISTERS MOVWF GP2 ; SAVE IN GP2 AND DECREMENT ON NETS ONE MOVLW MEMBAS+.20 ; GROUP REGISTER 1 BASE ADDRESS MOVWF FSR ; SAVE IN FILE SELECT POINTER CONV_2 MOVLW .8 ; NUMBER OF BITS IN BYTE (9) RESTORES CARRY MOVWF GP1 ; BIT COUNTER CONV_1 TSTF GP4 ; SETS Z FLAG IF CHANNEL ACTION IS REQUIRED BTFSC ZERO ; TEST FOR Z THIS MUST BE THE CHANNEL BSF INDIRECT,0 ; SET INDIRECT ONLY IF GP4 (CHANNEL) IS ZERO RRF INDIRECT,F ; ROLL INDIRECT (GROUP) THROUGH CARRY DECF GP4,F ; DECREASE GP4 (CHANNEL) DECFSZ GP1,F ; DECREASE BIT COUNT UNTIL BYTE FINISHED GOTO CONV_1 ; DO NEXT BIT RRF INDIRECT,F ; RESTORE CARRY TO CARRY POSITION INCF FSR,F ; SET TO NEXT BYTE (GROUP) DECFSZ GP2,F ; REDUCE REGISTER COUNT TIL ZERO GOTO CONV_2 ; DO NEXT REGISTER RETLW 0 ; EXIT ;-------------ROUTIENE TO CALCULATE THE EE BASE ADDRESS FOR GROUPS----- MULT CLRF GP2 ; CLEAR HIGH BYTE STORE CLRF EEOFFSET ; CLEAR LOW BYTE STORE MOVLW .4 ; MULTPLIER MOVWF GP5 ; SAVE AS GP5 MOVLW .8 ; NUMBER OF BITS MOVWF GP1 ; USE GP1 AS COUNTER MOVFW GP4 ; GET NUMBER TO BE MULTPLIED BCF CARRY ; CLEAR CARRY MULT_1 RRF GP5 ; FROM ECH AN526 MULTPLIER BTFSC CARRY ADDWF GP2,1 RRF GP2,1 RRF EEOFFSET,1 DECFSZ GP1 GOTO MULT_1 RETLW 0 ; RESULT IS IN EEOFFSET END