MPASM 03.90.01 Released ADC_RS232.ASM 9-5-2005 21:28:15 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 00000078 00018 count EQU 0x78 00000079 00019 count_buf EQU 0x79 00020 00000075 00021 del1 EQU 0x75 00000076 00022 del2 EQU 0x76 00000077 00023 del3 EQU 0x77 00024 00025 ;********************************************************************** 0000 00026 ORG 0x000 ; processor reset vector 0000 0000 00027 nop ; nop required for icd 0001 2810 00028 goto main ; go to beginning of program 00029 00030 0004 00031 ORG 0x004 ; interrupt vector location 0004 00032 int 0004 00F1 00033 movwf w_temp ; save off current W register contents 0005 0803 00034 movf STATUS,w ; move status register into W register 0006 00F2 00035 movwf status_temp ; save off contents of STATUS register 0007 080A 00036 movf PCLATH,w ; move pclath register into w register 0008 00F3 00037 movwf pclath_temp ; save off contents of PCLATH register 00038 00039 ; isr code can go here or be located as a call subroutine elsewhere 00040 0009 00041 intEnde 0009 0873 00042 movf pclath_temp,w ; retrieve copy of PCLATH register 000A 008A 00043 movwf PCLATH ; restore pre-isr PCLATH register contents 000B 0872 00044 movf status_temp,w ; retrieve copy of STATUS register 000C 0083 00045 movwf STATUS ; restore pre-isr STATUS register contents 000D 0EF1 00046 swapf w_temp,f 000E 0E71 00047 swapf w_temp,w ; restore pre-isr W register contents 000F 0009 00048 retfie ; return from interrupt 00049 00050 MPASM 03.90.01 Released ADC_RS232.ASM 9-5-2005 21:28:15 PAGE 2 LOC OBJECT CODE LINE SOURCE TEXT VALUE 0010 00051 main 00052 00053 ; remaining code goes here 0010 1283 00054 bcf STATUS, RP0 0011 1303 00055 bcf STATUS, RP1 0012 0186 00056 clrf PORTB 0013 1683 00057 bsf STATUS,RP0 0014 3000 00058 movlw 0x00 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0015 0086 00059 movwf TRISB 0016 1283 00060 bcf STATUS,RP0 0017 0186 00061 clrf PORTB 00062 0018 01F9 00063 clrf count_buf ;Clear count_buf register 0019 3040 00064 movlw 0x40 001A 00F8 00065 movwf count ;Load count with 64 00066 001B 204A 00067 call USART_initialize 001C 2051 00068 call USART_Baud_rate_adjust 001D 203F 00069 CALL ADC_initialize 00070 001E 00071 core_loop 001E 00072 change;Eingangsspannung 001E 1283 00073 bcf STATUS, RP0 001F 1303 00074 bcf STATUS, RP1 0020 151F 00075 BSF ADCON0, 2 ; ADC start 0021 00076 loop 0021 191F 00077 btfsc ADCON0, 2 ; is the ADC finished? 0022 2821 00078 goto loop ; no, continue to wait 00079 00080 ; Send ADRESH or ADRES to PORTB 00081 ; movfw ADRESH ; upper 8 bits pick out 00082 ; movwf PORTB ; upper 8-bits after PortB 0023 1683 00083 bsf STATUS, RP0 ; Bank1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 0024 081E 00084 movfw ADRESL ; upper 8 bits pick out 0025 1283 00085 bcf STATUS, RP0 ; Bank0 0026 0086 00086 movwf PORTB 00087 Message[305]: Using default destination of 1 (file). 0027 0BF8 00088 decfsz count ; Decrement count skip if zero 0028 2830 00089 goto reload 00090 0029 0878 00091 movfw count ; Place count to w register 002A 00F9 00092 movwf count_buf ; Place w to count_buf register Message[305]: Using default destination of 1 (file). 002B 03F9 00093 decf count_buf ; Decrease count_buf by one hence when 64->63....1->0 00094 002C 1683 00095 bsf STATUS, RP0 ; Bank1 Message[302]: Register in operand not in bank 0. Ensure that bank bits are correct. 002D 081E 00096 movfw ADRESL ; Load TO W the lower 2 bits from AD conversion DD00 0000 D->Dat a bits 002E 04F9 00097 iorwf count_buf,1 ; DD00 0000 OR ((63) 0011 1111