list P=PIC16F88 #include __CONFIG _CONFIG1, _INTRC_IO & _WDT_OFF & _PWRTE_ON &_LVP_OFF & _MCLR_OFF & _CCP1_RB3 __CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF ;***** VARIABLE DEFINITIONS w_temp EQU 0x0C ; variable used for context saving status_temp EQU 0x0D ; variable used for context saving tmp EQU 0x0F CNT0 EQU 0x20 CNT1 EQU 0x21 CNT2 EQU 0x22 CNT3 EQU 0x23 CNT4 EQU 0x24 w_temp0 EQU 0x25 w_temp1 EQU 0x26 w_temp2 EQU 0x27 w_temp3 EQU 0x28 w_temp4 EQU 0x29 ;********************************************************************** ;RESET_VECTOR CODE 0x000 ; processor reset vector org 0x000 goto Init ; go to beginning of program org 0x008 return Init: ;***** PORT mode set ***** ;RA0:3 binary out ;RB3 buzzer ;AN0:4 disable BCF INTCON,GIE ;Interrupt Disable BSF STATUS,RP0 ;Set page 1 CLRF TRISA CLRF TRISB CLRF ANSEL ; Analog input disable MOVLW 0x70 ; set INTOSC to 8Mhz MOVWF OSCCON MOVLW 0x7D MOVWF PR2 ; period 1 msec BCF STATUS,RP0 ;Set page 0 MOVLW 0xff MOVWF PORTA MOVWF PORTB MOVLW 0x3e MOVWF CCPR1L ; Duty cycle 50% MOVLW 0x06 MOVWF T2CON ; TMR2 on, pre scaler 16 Main: BCF PORTA,0 CALL Buzzer BSF PORTA,0 CALL Sleep1s GOTO Main ;***** Buzzer routines ***** ; Buzzer connected to PortB:3 ; 1kHz, 20 msec Buzzer: MOVWF w_temp4 MOVLW D'20' MOVWF CNT4 MOVLW 0x0c MOVWF CCP1CON ; CCP1 enable CALL Sleep1ms DECFSZ CNT4, F GOTO $-2 CLRF CCP1CON ; CCP1 disable BSF PORTB,3 MOVF w_temp4,W RETURN ;***** sleep routines ***** Sleep1s: MOVWF w_temp0 MOVLW D'10' MOVWF CNT0 CALL Sleep100ms DECFSZ CNT0, F GOTO $-2 CALL Sleep1ms CALL Sleep1ms CALL Sleep1ms MOVF w_temp0,W RETURN Sleep100ms: MOVWF w_temp1 MOVLW D'97' MOVWF CNT1 CALL Sleep1ms DECFSZ CNT1, F GOTO $-2 MOVF w_temp1,W RETURN Sleep1ms: MOVWF w_temp2 MOVLW D'256' MOVWF CNT2 Loop2: NOP NOP NOP NOP NOP DECFSZ CNT2, F GOTO Loop2 MOVF w_temp2,W RETURN END ; directive 'end of program'