;**************************************************************** ;* Name of Project: * ;* * ;**************************************************************** list P = 16F628 ;microcontroller include ;registers for F628 __Config 3F18h ;_cp_off & _lpv_off & _pwrte_off & _wdt_off & _intRC_oscI/O ;code protection - off ;low-voltage programming - off ;power-up timer - off ;watchdog timer - off ;use internal RC for 4MHz - all pins for in-out ;**************************************************************** ; Port definitions ;**************************************************************** PortA_Config equ 0xf1 ;bit7: in,in,in,in,out,out,out,in :bit0 PortB_Config equ 0x0f ;bit7: out,out,out,out,in,in,in,in :bit0 ;**************************************************************** ; variables - these are sample names and files ;**************************************************************** ;Files for F628 start at 20h but to make programs easily ; convertible from F84A to F628, we start at 20h. ;0Ch Not used - so F84A programs can be converted to F628 ; " "" """ """ ; " "" """ """ ;1Fh " "" """ """ timera equ 0x20 ;general purpose timer timerb equ 0x21 ;general purpose timer timerc equ 0x22 ;general purpose timer timerd equ 0x23 ;general purpose timer key equ 0x25 ;key last pressed steptemp equ 0x27 ;temporary step memory stepsgood equ 0x28 ;number of steps Alarm_state equ 0x29 ;contains alarm state State_save equ 0x2A Win_save equ 0x2B tmr_Flg1 equ 0x2C ;Register of timer flags tmr_Flg2 equ 0x2D ;Register of more timer flags Pulse_flgs equ 0X2E ;Pulse LED flags mi_flgs equ 0x2F ;miscellaneous flags count_clicks equ 0x30 table_i equ 0x31 ;table index ;-------------Miscellaneous flags flg_RAoff equ 0 ;Used to insure a double-click flg_Zone2 equ 1 ;Used to turn off motion detector (ZONE) 2 flg_Deboun equ 2 ;debouncing in progress flg_Waita equ 3 ;timer-2 flags flg_Waitb equ 4 ; " " flg_Trig equ 5 ; " " flg_Amp_On equ 6 flg_TEMP_On equ 7 ;**************************************************************** ;Beginning of program ;**************************************************************** reset: org 0x00 ;reset vector address goto SetUp ;goto SetUp nop nop nop ORG 4 ;interrupts go to this location GOTO isr1 ;Goto to Interrupt Service Routine ;**************************************************************** ;* port A and B initialisation * ;**************************************************************** SetUp bcf status,rp1 ;select bank 1 bsf status,rp0 movlw PortA_Config ;PortA Configuration movwf 0x05 movlw PortB_Config ;PortB Configuration movwf 0x06 movlw 0x88 ;Fosc/4;No prescaler movwf option ;Timer configuration bcf status,rp0 ;select programming area - bank0 clrf 0x05 ;Clear Port A of junk  clrf 0x06 ;Clear Port B of junk  movlw 0x07 ;turn comparators off and enable movwf cmcon ; pins for I/O functions goto Main ;**************************************************************** ;* Tables go here * ;**************************************************************** Table1 addwf 02,1 retlw 0x08 retlw 0x1A retlw 0xBE retlw 0xFF ;**************************************************************** ;* Interrupt Service Routine goes here * ;**************************************************************** isr1 movlw 0x80 movwf 0x2A ;**************************************************************** ;* Delay sub-routines go here * ;**************************************************************** Delay1 XXX ;Look at input line XXX ;Input LOW retlw 0x00 ;**************************************************************** ;* Main * ;**************************************************************** Main XXX btfss 06,3 ;Test the input line XXX XXX call Delay1 XXX bsf 0x06,0 ;Make the lowest output HIGH XXX call Table1 XXX goto Main END