processor 16f877 include __config _HS_OSC & _CP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON adaz equ h'2e' adel equ h'2f' j equ h'30' k equ h'3f' u1 equ h'31' u2 equ h'32' u3 equ h'33' az equ h'21' el equ h'22' azeq equ h'23' eleq equ h'24' ae40 equ h'40' ae41 equ h'41' ae42 equ h'42' ae43 equ h'43' ae44 equ h'44' ae45 equ h'45' ae46 equ h'46' ae47 equ h'47' ae48 equ h'48' ae49 equ h'49' ae50 equ h'50' ae51 equ h'51' ae52 equ h'52' ae53 equ h'53' ae54 equ h'54' ae55 equ h'55' ae56 equ h'56' ae57 equ h'57' ae58 equ h'58' ae59 equ h'59' ae60 equ h'60' ae61 equ h'61' ae62 equ h'62' ae63 equ h'63' ae64 equ h'64' ae65 equ h'65' ae66 equ h'66' ae67 equ h'67' ae68 equ h'68' ae69 equ h'69' ae70 equ h'70' ae71 equ h'71' ae72 equ h'72' ae73 equ h'73' ae74 equ h'74' ae75 equ h'75' ae76 equ h'76' org 0 clrf STATUS clrf INTCON clrf PORTA clrf PORTB clrf PORTC clrf PORTD clrf PORTE bsf STATUS,RP0 bcf STATUS,RP1 clrf PIE1 clrf PIE2 movlw b'00000010' movwf ADCON1 bsf TXSTA,TXEN movlw d'129' movwf SPBRG movlw b'11001001' movwf TRISB bcf STATUS,RP0 bsf RCSTA,SPEN bsf RCSTA,CREN movlw h'01' movwf azeq movwf eleq movlw h'80' movwf az movwf el movlw h'00' movwf ae40 movlw h'07' movwf ae41 movlw h'0e' movwf ae42 movlw h'15' movwf ae43 movlw h'1c' movwf ae44 movlw h'23' movwf ae45 movlw h'2a' movwf ae46 movlw h'32' movwf ae47 movlw h'38' movwf ae48 movlw h'40' movwf ae49 movlw h'47' movwf ae50 movlw h'4e' movwf ae51 movlw h'55' movwf ae52 movlw h'5c' movwf ae53 movlw h'63' movwf ae54 movlw h'6a' movwf ae55 movlw h'71' movwf ae56 movlw h'78' movwf ae57 movlw h'80' movwf ae58 movlw h'87' movwf ae59 movlw h'8e' movwf ae60 movlw h'95' movwf ae61 movlw h'9c' movwf ae62 movlw h'a3' movwf ae63 movlw h'aa' movwf ae64 movlw h'b1' movwf ae65 movlw h'b8' movwf ae66 movlw h'c0' movwf ae67 movlw h'c7' movwf ae68 movlw h'ce' movwf ae69 movlw h'd5' movwf ae70 movlw h'dc' movwf ae71 movlw h'e3' movwf ae72 movlw h'ea' movwf ae73 movlw h'f1' movwf ae74 movlw h'f6' movwf ae75 movlw h'ff' movwf ae76 movlw b'11000001' movwf ADCON0 main call uart call azmot call elmot call uartx goto main testp bsf STATUS,RP0 movlw h'00' movwf TRISA movwf TRISC bcf STATUS,RP0 movlw h'ff' movwf PORTA movwf PORTC call acqt movlw h'00' movwf PORTA movwf PORTC call acqt bsf STATUS,RP0 movlw h'ff' movwf TRISA movwf TRISC bcf STATUS,RP0 return uartx bsf STATUS,RP0 btfss TXSTA,TRMT goto uartx bcf STATUS,RP0 movlw h'57' movwf TXREG return uart btfss PIR1,RCIF return movf RCREG,0 sublw h'57' btfss STATUS,Z return call urone ursp btfss PIR1,RCIF goto ursp movf RCREG,0 sublw h'20' btfss STATUS,Z return movf INDF,0 addwf u3,0 movwf az movlw h'01' movwf azeq call urone movf INDF,0 addwf u3,0 movwf el movlw h'01' movwf eleq crlf btfss PIR1,RCIF goto crlf movf RCREG,0 return urone btfss PIR1,RCIF goto urone movf RCREG,0 andlw h'0f' addlw h'04' movwf u1 swapf u1,1 urtwo btfss PIR1,RCIF goto urtwo movf RCREG,0 andlw h'0f' addwf u1,0 movwf FSR urthr btfss PIR1,RCIF goto urthr movf RCREG,0 andlw h'0f' movwf u3 return azmot btfss azeq,0 return movlw b'11000001' movwf ADCON0 call acqt bsf ADCON0,GO call atod movf ADRESH,0 movwf adaz subwf az,0 btfss STATUS,Z goto azbor bcf PORTB,1 bcf PORTB,2 clrf azeq return azbor movf adaz,0 subwf az,0 btfss STATUS,C goto azrev bcf PORTB,1 bsf PORTB,2 movlw h'01' movwf azeq return azrev bcf PORTB,2 bsf PORTB,1 movlw h'01' movwf azeq return elmot btfss eleq,0 return movlw b'11001001' movwf ADCON0 call acqt bsf ADCON0,GO call atod movf ADRESH,0 movwf adel subwf el,0 btfss STATUS,Z goto elbor bcf PORTB,4 bcf PORTB,5 clrf eleq return elbor movf adel,0 subwf el,0 btfss STATUS,C goto elrev bcf PORTB,4 bsf PORTB,5 movlw h'01' movwf eleq return elrev bcf PORTB,5 bsf PORTB,4 movlw h'01' movwf eleq return atod btfss ADCON0,GO return goto atod acqt movlw h'80' movwf j jloop decfsz j,1 goto jloop return end