hi San,
This is quick test program for your project.
Load the Ping1.hex into your 16F877A, it should display on PORTB, [CCPR1H] and on PORTD [CCPR1L] register contents. [NOT the actual range, there is no processing of the CCPR1 count]
The update/refresh Rate is 10/second
The Oshonsoft Basic is for reference ONLY, to show the sequence of the program.
Code:
PORTB = 0
TRISB = 0
PORTD = 0
TRISD = 0
main:
TRISC.2 = 0
PORTC.2 = 1
WaitUs 5
PORTC.2 = 0
WaitUs 750
TRISC.2 = 1
TMR1H = 0
TMR1L = 0
T1CON = 0x30
While PORTC.2 = 0
Wend
T1CON.TMR1ON = 1
CCP1CON = 0x04
While PIR1.CCP1IF = 0
Wend
CCP1CON = 0
PIR1.CCP1IF = 0
T1CON.TMR1ON = 0
PORTB = CCPR1H
PORTD = CCPR1L
WaitMs 100
Goto main