MPASM 03.90.01 Released ADC_RS232.ASM 9-5-2005 21:28:55 PAGE 1 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00001 00002 list p=16f876A ; list directive to define processor 00003 #include ; processor specific variable definitions 00001 LIST 00002 ; P16F876A.INC Standard Header File, Version 1.00 Microchip Technology, Inc. 00380 LIST 00004 2007 3F32 00005 __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _HS_OSC & _WRT_OFF & _LVP_OFF & _CPD_OFF 00006 00007 ; '__CONFIG' directive is used to embed configuration data within .asm file. 00008 ; The lables following the directive are located in the respective .inc file. 00009 ; See respective data sheet for additional information on configuration word. 00010 00011 00012 ;***** VARIABLE DEFINITIONS 00000071 00013 w_temp EQU 0x71 ; variable used for context saving 00000072 00014 status_temp EQU 0x72 ; variable used for context saving 00000073 00015 pclath_temp EQU 0x73 ; variable used for context saving 00016 00000074 00017 indications EQU 0x74 00018 00000075 00019 del1 EQU 0x75 00000076 00020 del2 EQU 0x76 00000077 00021 del3 EQU 0x77 00022 00023 ;********************************************************************** 0000 00024 ORG 0x000 ; processor reset vector 0000 0000 00025 nop ; nop required for icd 0001 2810 00026 goto main ; go to beginning of program 00027 00028 0004 00029 ORG 0x004 ; interrupt vector location 0004 00030 int 0004 00F1 00031 movwf w_temp ; save off current W register contents 0005 0803 00032 movf STATUS,w ; move status register into W register 0006 00F2 00033 movwf status_temp ; save off contents of STATUS register 0007 080A 00034 movf PCLATH,w ; move pclath register into w register 0008 00F3 00035 movwf pclath_temp ; save off contents of PCLATH register 00036 00037 ; isr code can go here or be located as a call subroutine elsewhere 00038 0009 00039 intEnde 0009 0873 00040 movf pclath_temp,w ; retrieve copy of PCLATH register 000A 008A 00041 movwf PCLATH ; restore pre-isr PCLATH register contents 000B 0872 00042 movf status_temp,w ; retrieve copy of STATUS register 000C 0083 00043 movwf STATUS ; restore pre-isr STATUS register contents 000D 0EF1 00044 swapf w_temp,f 000E 0E71 00045 swapf w_temp,w ; restore pre-isr W register contents 000F 0009 00046 retfie ; return from interrupt 00047 00048 0010 00049 main 00050 MPASM 03.90.01 Released ADC_RS232.ASM 9-5-2005 21:28:55 PAGE 2 LOC OBJECT CODE LINE SOURCE TEXT VALUE 00051 ; remaining code goes here 0010 1283 00052 bcf STATUS, RP0 0011 1303 00053 bcf STATUS, RP1 0012 0186 00054 clrf PORTB 0013 1683 00055 bsf STATUS,RP0 0014 3000 00056 movlw 0x00 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0015 0086 00057 movwf TRISB 0016 1283 00058 bcf STATUS,RP0 0017 0186 00059 clrf PORTB 00060 0018 203B 00061 call USART_initialize 0019 2042 00062 call USART_Baud_rate_adjust 001A 2030 00063 CALL ADC_initialize 00064 001B 00065 core_loop 001B 00066 change;Eingangsspannung 001B 1283 00067 bcf STATUS, RP0 001C 1303 00068 bcf STATUS, RP1 001D 151F 00069 BSF ADCON0, 2 ; ADC start 001E 00070 loop 001E 191F 00071 btfsc ADCON0, 2 ; is the ADC finished? 001F 281E 00072 goto loop ; no, continue to wait 00073 00074 ; Send ADRESH or ADRES to PORTB 00075 ; movfw ADRESH ; upper 8 bits pick out 00076 ; movwf PORTB ; upper 8-bits after PortB 0020 1683 00077 bsf STATUS, RP0 ; Bank1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0021 081E 00078 movfw ADRESL ; upper 8 bits pick out 0022 1283 00079 bcf STATUS, RP0 ; Bank0 0023 0086 00080 movwf PORTB 00081 0024 00082 RS232outADRESH 0024 1E0C 00083 btfss PIR1, TXIF ; is transmitter empty? 0025 2824 00084 goto RS232outADRESH ; no, not yet empty 0026 081E 00085 movfw ADRESH ; ADRESH byte get 0027 0099 00086 movwf TXREG ; and into the RS232-Sender write 0028 00087 RS232outADRESL 0028 1E0C 00088 btfss PIR1, TXIF ; is transmitter empty? 0029 2828 00089 goto RS232outADRESL ; no, not yet empty 002A 1683 00090 BSF STATUS, RP0 ; Bank1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 002B 081E 00091 movfw ADRESL ; ADRESL byte get 002C 1283 00092 BCF STATUS, RP0 ; Bank0 002D 0099 00093 movwf TXREG 00094 002E 2046 00095 call delay 00096 002F 281B 00097 goto core_loop 00098 00099 ;*********************SUBROUTINES************************ 00100 MPASM 03.90.01 Released ADC_RS232.ASM 9-5-2005 21:28:55 PAGE 3 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0030 00101 ADC_initialize 0030 1283 00102 bcf STATUS, RP0 ; Bank0 00103 ; ADC switch on 0031 141F 00104 BSF ADCON0, 0 ; ADON=1 00105 ; ADC entrance AN0 select 0032 129F 00106 BCF ADCON0, 5 ; ADCHS2=0 0033 121F 00107 BCF ADCON0, 4 ; ADCHS1=0 0034 119F 00108 BCF ADCON0, 3 ; ADCHS0=0 00109 ; ADC speed for 20 MHz adjust 0035 179F 00110 BSF ADCON0, 7 ; ADCS1=1 0036 131F 00111 BCF ADCON0, 6 ; ADCS0=0 00112 ; Data left justified 0037 1683 00113 BSF STATUS, RP0 ; Bank1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0038 139F 00114 BCF ADCON1, 7 ; ADFM=0 0039 1283 00115 BCF STATUS, RP0 ; Bank0 003A 0008 00116 RETURN 00117 003B 00118 USART_initialize 003B 1683 00119 BSF STATUS, RP0 ; Bank1 003C 3024 00120 MOVLW 0x24 ; Transmitter:RS232 , BRGH bit is set Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 003D 0098 00121 MOVWF TXSTA ; 003E 1283 00122 BCF STATUS, RP0 ; Bank 0 003F 3090 00123 MOVLW 0x90 ; Enable serial port, 8bit reception , 0040 0098 00124 MOVWF RCSTA ; continuous receive 0041 0008 00125 RETURN 00126 0042 00127 USART_Baud_rate_adjust 0042 1683 00128 BSF STATUS, RP0 ; Bank1 0043 3020 00129 MOVLW 0x20 ; Set Baud Rate 38400 KB with Fosc=20MHz Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0044 0099 00130 MOVWF SPBRG 0045 0008 00131 RETURN 00132 0046 00133 delay 0046 1283 00134 bcf STATUS,RP0 00135 0047 3005 00136 d2 movlw 0x5 0048 00F6 00137 movwf del2 0049 30FF 00138 d1 movlw 0xff 004A 00F7 00139 movwf del3 004B 0BF7 00140 d3 decfsz del3,f 004C 284B 00141 goto d3 004D 0BF6 00142 decfsz del2,f 004E 2849 00143 goto d1 00144 004F 0008 00145 return 00146 00147 END ; directive 'end of program' MPASM 03.90.01 Released ADC_RS232.ASM 9-5-2005 21:28:55 PAGE 4 SYMBOL TABLE LABEL VALUE ACKDT 00000005 ACKEN 00000004 ACKSTAT 00000006 ADCON0 0000001F ADCON1 0000009F ADCS0 00000006 ADCS1 00000007 ADC_initialize 00000030 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 MPASM 03.90.01 Released ADC_RS232.ASM 9-5-2005 21:28:55 PAGE 5 SYMBOL TABLE LABEL VALUE CM1 00000001 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 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 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 NOT_POR 00000001 NOT_RBPU 00000007 MPASM 03.90.01 Released ADC_RS232.ASM 9-5-2005 21:28:55 PAGE 6 SYMBOL TABLE LABEL VALUE NOT_RC8 00000006 NOT_T1SYNC 00000002 NOT_TO 00000004 NOT_TX8 00000006 NOT_W 00000002 NOT_WRITE 00000002 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 PR2 00000092 PS0 00000000 PS1 00000001 PS2 00000002 PSA 00000003 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 RS232outADRESH 00000024 RS232outADRESL 00000028 RSEN 00000001 RX9 00000006 RX9D 00000000 R_W 00000002 S 00000003 SEN 00000000 MPASM 03.90.01 Released ADC_RS232.ASM 9-5-2005 21:28:55 PAGE 7 SYMBOL TABLE LABEL VALUE 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 TMR1CS 00000001 TMR1H 0000000F TMR1IE 00000000 TMR1IF 00000000 TMR1L 0000000E TMR1ON 00000000 TMR2 00000011 TMR2IE 00000001 TMR2IF 00000001 TMR2ON 00000002 TOUTPS0 00000003 TOUTPS1 00000004 TOUTPS2 00000005 TOUTPS3 00000006 TRISA 00000085 TRISB 00000086 TRISC 00000087 TRMT 00000001 TX8_9 00000006 TX9 00000006 MPASM 03.90.01 Released ADC_RS232.ASM 9-5-2005 21:28:55 PAGE 8 SYMBOL TABLE LABEL VALUE TX9D 00000000 TXD8 00000000 TXEN 00000005 TXIE 00000004 TXIF 00000004 TXREG 00000019 TXSTA 00000098 UA 00000001 USART_Baud_rate_adjust 00000042 USART_initialize 0000003B 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 __16F876A 00000001 change 0000001B core_loop 0000001B d1 00000049 d2 00000047 d3 0000004B del1 00000075 del2 00000076 del3 00000077 delay 00000046 indications 00000074 int 00000004 intEnde 00000009 loop 0000001E main 00000010 MPASM 03.90.01 Released ADC_RS232.ASM 9-5-2005 21:28:55 PAGE 9 SYMBOL TABLE LABEL VALUE pclath_temp 00000073 status_temp 00000072 w_temp 00000071 MEMORY USAGE MAP ('X' = Used, '-' = Unused) 0000 : XX--XXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX 0040 : XXXXXXXXXXXXXXXX ---------------- ---------------- ---------------- 2000 : -------X-------- ---------------- ---------------- ---------------- All other memory blocks unused. Program Memory Words Used: 78 Program Memory Words Free: 8114 Errors : 0 Warnings : 0 reported, 0 suppressed Messages : 6 reported, 0 suppressed