LOOP: SETB P1.7 ;1
MOV R0,#02H ;1
BACK1: NOP ;1 |
NOP ;1 |X2 = 8
DJNZ RO,BACK1 ;2 |
NOP ;1
NOP ;1
NOP ;1
CLRB P1.7 ;1
MOV R0,#02H ;1
BACK2: NOP ;1 |
NOP ;1 |X2 = 8
DJNZ RO,BACK2 ;2 |
SJMP LOOP ;2
; _______
;TOTAL: 25 CYCLES
main:
dim i as integer
TRISA=0
for i = 1 to 9
PORTA.4=1
Delay_ms(2)
PORTA.4=0
Delay_ms(0.5)
next i
what do u mean, plz anyone answer me ??maybe it's impotrant thing that he said??!!!you can set up the pwm to run the 38khz IR pulse in the background, while the pic handles the logic.
PING:
PING_LOOP = 8 ' Number of cycles in ping
PING1:
PORTB = %00010000 ' 1st half of cycle
Delayus 10 ' Create a delay of 10uS
PORTB = %00100000 ' 2nd half of cycle
Delayus 9 ' Create a delay of 9uS
Djnz PING_LOOP,PING1 ' Special mnemonic to form a fast loop
Return
hi jim thank u for the great file, but there is somthing in that file i couldn't understand look at this code:
Code:PING: PING_LOOP = 8 ' Number of cycles in ping
The above command sets a limit variable so that 8 cycles of 40kHz will be generated per "blip".
Code:PING1: PORTB = %00010000 ' 1st half of cycle Delayus 10 ' Create a delay of 10uS PORTB = %00100000 ' 2nd half of cycle Delayus 9 ' Create a delay of 9uS
The above code sets all port B pins low except for one pin on one leg of the ultrasonic TX transducer, then waits 10 microseconds, then sets that pin low and sets the other leg of the transducer high. Then it waits for another 9 microseconds. By alternating between low and high on the two legs of the transducer and using the delay values given, a tone very close to 40kHz is produced.
Code:Djnz PING_LOOP,PING1 ' Special mnemonic to form a fast loop Return
The above line decrements the variable PING_LOOP and checks whether it has become 0. If PING_LOOP is not yet 0, then the program jumps back to the line which has the label 'PING1:'. The assembler command 'DJNZ' means "Decrement Jump if Not Zero"--i.e. decrement the variable given as the second argument, and if the result of the decrement is not zero, then jump to the label given as the second argument.
i mean they r saying that this code suppose to generate 40 KHz!! how ?
i know i ask alot, but plz can any one answer me..
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?