ultrasonic sensor interfecaing pic16f877a asm code

Submitted by moz on

hello

well i'm a beginner in asm coding ..and i have this project to set a code for ultrasonic sensor with pic16f877a using assembly langauge ( which i don't know very well)  to display a distance in 7seg_ .. ..i started with this little code but can't understand how to go further plz help me 

                                                               

TRIG   equ  0x0c
count  equ  0x0c
count1 equ  0x0c
count2 equ  0x0c
;*****************************************
ORG 0x00
GOTO START ; reset vector
ORG 0x04
GOTO INTERRUPT ; interruption vector
 
;;*************INITIALISATION*********
 
 
START clrf    PIE1
bsf status,5
bcf status,6  ; bank1
movlw 0x07
movwf adcon1
CLRF TRISD
CLRF TRISC
clrf TRISB
bcf TRISA,0
bsf TRISA,1     ; RA0 is TRIG  RA1 is ECHO
bsf option_reg,6
bsf PIE1,TMR1IE
 
bcf status,5
movlw   0x29
        movwf   T1CON    ;Prescaller 1:4
        bsF     INTCON,PEIE
bcf INTCON,GIE
clrf    TMR1L
CLRF TMR1H
goto ULTRA
 
 
;**************************************
 
ULTRA bsf PORTA,0
movlw 0x02
movwf TRIG
TRIGG decfsz TRIG,1   ; 10us
GOTO TRIGG
nop
bcf PORTB,2
ECHO
HIGH btfss   PORTA,1  ; test if echo high
goto    HIGH
bsf     INTCON,7
 
LOW         btfsc PORTA,1  ; test echo if low
goto LOW
bcf INTCON,GIE
CLRF COUNT
CLRF COUNT1
CLRF COUNT2
goto    ULTRA

  

Hi, did you manage to finish it?

  Joined June 09, 2023      1
Friday at 08:07 AM