MPASM 03.70.01 Released PULSE.ASM 3-28-2006 22:24:42 PAGE 1 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00001 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 00002 ; 00003 ; PULSE.ASM MPB 21-8-05 00004 ; Generates timed output interval using Timer 2 00005 ; in compare mode 00006 ; Timer interrupt sets output, cleared after 1ms 00007 ; 00008 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 00009 00010 PROCESSOR 16F877A 00011 ; Clock = XT 4MHz, standard fuse settings 2007 3731 00012 __CONFIG 0x3731 00013 00014 ; LABEL EQUATES ...................................... 00015 00016 INCLUDE "P16F877A.INC" ; Standard register labels 00001 LIST 00002 ; P16F877A.INC Standard Header File, Version 1.00 Microchip Technology, Inc. 00398 LIST 00017 00000020 00018 Count EQU 20 ; soft timer 00019 00020 ; Program begins ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 00021 0000 00022 ORG 0 ; Place machine code 0000 0000 00023 NOP ; for ICD mode 0001 2805 00024 GOTO init ; Jump over ISR vector 00025 0004 00026 ORG 4 ; ISR vector address 0004 2820 00027 GOTO isr ; run ISR 00028 0005 0000 00029 init NOP 0006 1683 1303 00030 BANKSEL TRISC ; Select bank 1 0008 30FB 00031 MOVLW B'11111011' ; RC2 = output Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0009 0087 00032 MOVWF TRISC ; Initialise display port 000A 3004 00033 MOVLW B'00000100' ; Timer1 interrupt.. Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 000B 008C 00034 MOVWF PIE1 ; ..enable 00035 000C 1283 1303 00036 BANKSEL PORTC ; Select bank 0 000E 0187 00037 CLRF PORTC ; Clear output 000F 30C0 00038 MOVLW B'11000000' ; Peripheral interupt.. 0010 008B 00039 MOVWF INTCON ; ..enable 0011 3008 00040 MOVLW B'00001000' ; Compare mode.. 0012 0097 00041 MOVWF CCP1CON ; ..set output on match 0013 3027 00042 MOVLW 027 ; Initial value.. 0014 0096 00043 MOVWF CCPR1H ; .. for high byte (10ms) 0015 3010 00044 MOVLW 010 ; Initial value.. 0016 0095 00045 MOVWF CCPR1L ; .. for low byte (10ms) 0017 3001 00046 MOVLW B'00000001' ; Timer1 enable.. 0018 0090 00047 MOVWF T1CON ; with internal clock (1MHz) 00048 MPASM 03.70.01 Released PULSE.ASM 3-28-2006 22:24:42 PAGE 2 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0019 2831 00049 GOTO start ; Jump to main program 00050 00051 ; SUBROUTINES............................................ 00052 00053 ; 1ms delay with 1us cycle time (1000 cycles) 00054 001A 30F9 00055 onems MOVLW D'249' ; Count for 1ms delay 001B 00A0 00056 MOVWF Count ; Load count 001C 0000 00057 loop NOP ; Pad for 4 cycle loop Message[305]: Using default destination of 1 (file). 001D 0BA0 00058 DECFSZ Count ; Count 001E 281C 00059 GOTO loop ; until Z 001F 0008 00060 RETURN ; and finish 00061 00062 00063 ; INTERRUPT SERVICE ROUTINE.............................. 00064 00065 ; Reset interrupt, check buttons, generate 1ms pulse 00066 0020 018C 00067 isr CLRF PIR1 ; clear interrupt flags 0021 018F 00068 CLRF TMR1H ; clear timer high.. 0022 018E 00069 CLRF TMR1L ; ..and low byte 00070 0023 1808 00071 BTFSC PORTD,0 ; dec frequency button? 0024 2828 00072 GOTO other ; no Message[305]: Using default destination of 1 (file). 0025 0F96 00073 INCFSZ CCPR1H ; yes, inc period, zero? 0026 2828 00074 GOTO other ; no Message[305]: Using default destination of 1 (file). 0027 0396 00075 DECF CCPR1H ; yes, step back 00076 0028 1888 00077 other BTFSC PORTD,1 ; inc frequency button? 0029 282D 00078 GOTO wait ; no Message[305]: Using default destination of 1 (file). 002A 0B96 00079 DECFSZ CCPR1H ; yes, inc period, zero? 002B 282D 00080 GOTO wait ; no Message[305]: Using default destination of 1 (file). 002C 0A96 00081 INCF CCPR1H ; yes, step back 00082 002D 201A 00083 wait CALL onems ; wait 1ms 002E 1197 00084 BCF CCP1CON,3 ; clear output 002F 1597 00085 BSF CCP1CON,3 ; re-enable timer mode 00086 0030 0009 00087 RETFIE ; return to main program 00088 00089 00090 ;----------------------------------------------------------- 00091 ; Main program 00092 ;----------------------------------------------------------- 0031 2831 00093 start GOTO start ; wait for timer interrupt 00094 END ; of source code MPASM 03.70.01 Released PULSE.ASM 3-28-2006 22:24:42 PAGE 3 SYMBOL TABLE LABEL VALUE ACKDT 00000005 ACKEN 00000004 ACKSTAT 00000006 ADCON0 0000001F ADCON1 0000009F ADCS0 00000006 ADCS1 00000007 ADDEN 00000003 ADFM 00000007 ADIE 00000006 ADIF 00000006 ADON 00000000 ADRESH 0000001E ADRESL 0000009E BCLIE 00000003 BCLIF 00000003 BF 00000000 BRGH 00000002 C 00000000 C1INV 00000004 C1OUT 00000006 C2INV 00000005 C2OUT 00000007 CCP1CON 00000017 CCP1IE 00000002 CCP1IF 00000002 CCP1M0 00000000 CCP1M1 00000001 CCP1M2 00000002 CCP1M3 00000003 CCP1X 00000005 CCP1Y 00000004 CCP2CON 0000001D CCP2IE 00000000 CCP2IF 00000000 CCP2M0 00000000 CCP2M1 00000001 CCP2M2 00000002 CCP2M3 00000003 CCP2X 00000005 CCP2Y 00000004 CCPR1H 00000016 CCPR1L 00000015 CCPR2H 0000001C CCPR2L 0000001B CHS0 00000003 CHS1 00000004 CHS2 00000005 CIS 00000003 CKE 00000006 CKP 00000004 CM0 00000000 CM1 00000001 MPASM 03.70.01 Released PULSE.ASM 3-28-2006 22:24:42 PAGE 4 SYMBOL TABLE LABEL VALUE CM2 00000002 CMCON 0000009C CMIE 00000006 CMIF 00000006 CREN 00000004 CSRC 00000007 CVR0 00000000 CVR1 00000001 CVR2 00000002 CVR3 00000003 CVRCON 0000009D CVREN 00000007 CVROE 00000006 CVRR 00000005 Count 00000020 D 00000005 DATA_ADDRESS 00000005 DC 00000001 D_A 00000005 EEADR 0000010D EEADRH 0000010F EECON1 0000018C EECON2 0000018D EEDATA 0000010C EEDATH 0000010E EEIE 00000004 EEIF 00000004 EEPGD 00000007 F 00000001 FERR 00000002 FSR 00000004 GCEN 00000007 GIE 00000007 GO 00000002 GO_DONE 00000002 I2C_DATA 00000005 I2C_READ 00000002 I2C_START 00000003 I2C_STOP 00000004 IBF 00000007 IBOV 00000005 INDF 00000000 INTCON 0000000B INTE 00000004 INTEDG 00000006 INTF 00000001 IRP 00000007 NOT_A 00000005 NOT_ADDRESS 00000005 NOT_BO 00000000 NOT_BOR 00000000 NOT_DONE 00000002 NOT_PD 00000003 MPASM 03.70.01 Released PULSE.ASM 3-28-2006 22:24:42 PAGE 5 SYMBOL TABLE LABEL VALUE NOT_POR 00000001 NOT_RBPU 00000007 NOT_RC8 00000006 NOT_T1SYNC 00000002 NOT_TO 00000004 NOT_TX8 00000006 NOT_W 00000002 NOT_WRITE 00000002 OBF 00000006 OERR 00000001 OPTION_REG 00000081 P 00000004 PCFG0 00000000 PCFG1 00000001 PCFG2 00000002 PCFG3 00000003 PCL 00000002 PCLATH 0000000A PCON 0000008E PEIE 00000006 PEN 00000002 PIE1 0000008C PIE2 0000008D PIR1 0000000C PIR2 0000000D PORTA 00000005 PORTB 00000006 PORTC 00000007 PORTD 00000008 PORTE 00000009 PR2 00000092 PS0 00000000 PS1 00000001 PS2 00000002 PSA 00000003 PSPIE 00000007 PSPIF 00000007 PSPMODE 00000004 R 00000002 RBIE 00000003 RBIF 00000000 RC8_9 00000006 RC9 00000006 RCD8 00000000 RCEN 00000003 RCIE 00000005 RCIF 00000005 RCREG 0000001A RCSTA 00000018 RD 00000000 READ_WRITE 00000002 RP0 00000005 RP1 00000006 MPASM 03.70.01 Released PULSE.ASM 3-28-2006 22:24:42 PAGE 6 SYMBOL TABLE LABEL VALUE RSEN 00000001 RX9 00000006 RX9D 00000000 R_W 00000002 S 00000003 SEN 00000000 SMP 00000007 SPBRG 00000099 SPEN 00000007 SREN 00000005 SSPADD 00000093 SSPBUF 00000013 SSPCON 00000014 SSPCON2 00000091 SSPEN 00000005 SSPIE 00000003 SSPIF 00000003 SSPM0 00000000 SSPM1 00000001 SSPM2 00000002 SSPM3 00000003 SSPOV 00000006 SSPSTAT 00000094 STATUS 00000003 SYNC 00000004 T0CS 00000005 T0IE 00000005 T0IF 00000002 T0SE 00000004 T1CKPS0 00000004 T1CKPS1 00000005 T1CON 00000010 T1INSYNC 00000002 T1OSCEN 00000003 T1SYNC 00000002 T2CKPS0 00000000 T2CKPS1 00000001 T2CON 00000012 TMR0 00000001 TMR0IE 00000005 TMR0IF 00000002 TMR1CS 00000001 TMR1H 0000000F TMR1IE 00000000 TMR1IF 00000000 TMR1L 0000000E TMR1ON 00000000 TMR2 00000011 TMR2IE 00000001 TMR2IF 00000001 TMR2ON 00000002 TOUTPS0 00000003 TOUTPS1 00000004 MPASM 03.70.01 Released PULSE.ASM 3-28-2006 22:24:42 PAGE 7 SYMBOL TABLE LABEL VALUE TOUTPS2 00000005 TOUTPS3 00000006 TRISA 00000085 TRISB 00000086 TRISC 00000087 TRISD 00000088 TRISE 00000089 TRISE0 00000000 TRISE1 00000001 TRISE2 00000002 TRMT 00000001 TX8_9 00000006 TX9 00000006 TX9D 00000000 TXD8 00000000 TXEN 00000005 TXIE 00000004 TXIF 00000004 TXREG 00000019 TXSTA 00000098 UA 00000001 W 00000000 WCOL 00000007 WR 00000001 WREN 00000002 WRERR 00000003 Z 00000002 _BODEN_OFF 00003FBF _BODEN_ON 00003FFF _CPD_OFF 00003FFF _CPD_ON 00003EFF _CP_ALL 00001FFF _CP_OFF 00003FFF _DEBUG_OFF 00003FFF _DEBUG_ON 000037FF _HS_OSC 00003FFE _LP_OSC 00003FFC _LVP_OFF 00003F7F _LVP_ON 00003FFF _PWRTE_OFF 00003FFF _PWRTE_ON 00003FF7 _RC_OSC 00003FFF _WDT_OFF 00003FFB _WDT_ON 00003FFF _WRT_1FOURTH 00003BFF _WRT_256 00003DFF _WRT_HALF 000039FF _WRT_OFF 00003FFF _XT_OSC 00003FFD __16F877A 00000001 init 00000005 isr 00000020 loop 0000001C MPASM 03.70.01 Released PULSE.ASM 3-28-2006 22:24:42 PAGE 8 SYMBOL TABLE LABEL VALUE onems 0000001A other 00000028 start 00000031 wait 0000002D MEMORY USAGE MAP ('X' = Used, '-' = Unused) 0000 : XX--XXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XX-------------- 2000 : -------X-------- ---------------- ---------------- ---------------- All other memory blocks unused. Program Memory Words Used: 48 Program Memory Words Free: 8144 Errors : 0 Warnings : 0 reported, 0 suppressed Messages : 7 reported, 0 suppressed Error[173] : source file path exceeds 62 characters (C:\A PIC INTERFACING BOOK PROJECT\PIC INTERFACING BOOK APPLICATIONS MARCH 06\A PPLICATIONS\CHAP06\PULSE\PULSE.ASM) Error[173] : source file path exceeds 62 characters (C:\A PIC INTERFACING BOOK PROJECT\PIC INTERFACING BOOK APPLICATIONS MARCH 06\A PPLICATIONS\CHAP06\PULSE\P16F877A.INC)