Truncated match.
PICList
Thread
'Driving a ultrasonic transducer from a PIC (fwd)'
1995\12\06@172648
by
Rolan
|
many people have requested the code. I shouldn't post it without
trying it, but here it is. I hope this is the right program.
If this one does not give you
a clean 40 kHz, then I will dig deep into my tape backups to find the
right one. I kind of remember taking out the swl (small wait loop)
and replacing it with a few nop's and then a return. Well, play with
it and see what you get.
Remember to use a 16c84 and a 1 Mhz oscillator.
include <p16cxx.inc>
lo equ 0
hi equ 1
inuse equ 2
level equ 0ch
level2 equ 0dh
counter equ 0eh
durat equ 0fh
tmpout equ 10h
org 0x0000
goto init
org 0x0010
init
bsf status,rp0
movlw B'00000000'
movwf TRISB
movlw B'00011111'
movwf trisa
bcf status,rp0
movlw 0x01
movwf portb
movwf tmpout
begin ;main program
call chirp
call pause
goto begin
chirp ;make sound for dur
movlw 0x30
movwf durat
cycle bsf tmpout,0 ;on and offs
movfw tmpout
movwf portb
call smwait
bcf tmpout,0
movfw tmpout
movwf portb
call smwait
decfsz durat
return
goto cycle
smwait ;small wait loop
movlw 0xff
movwf level
swl
decfsz level
goto swl
return
pause ;big wait loop
movlw 0xff
movwf level
movlw 0x10
movwf level2
loop
decfsz level2,1
goto next
return
next decfsz level,1
goto next
goto loop
end
1995\12\06@183023
by
Rolan
|
many people have requested the code. I shouldn't post it without
trying it, but here it is. I hope this is the right program.
If this one does not give you
a clean 40 kHz, then I will dig deep into my tape backups to find the
right one. I kind of remember taking out the swl (small wait loop)
and replacing it with a few nop's and then a return. Well, play with
it and see what you get.
Remember to use a 16c84 and a 1 Mhz oscillator.
include <p16cxx.inc>
lo equ 0
hi equ 1
inuse equ 2
level equ 0ch
level2 equ 0dh
counter equ 0eh
durat equ 0fh
tmpout equ 10h
org 0x0000
goto init
org 0x0010
init
bsf status,rp0
movlw B'00000000'
movwf TRISB
movlw B'00011111'
movwf trisa
bcf status,rp0
movlw 0x01
movwf portb
movwf tmpout
begin ;main program
call chirp
call pause
goto begin
chirp ;make sound for dur
movlw 0x30
movwf durat
cycle bsf tmpout,0 ;on and offs
movfw tmpout
movwf portb
call smwait
bcf tmpout,0
movfw tmpout
movwf portb
call smwait
decfsz durat
return
goto cycle
smwait ;small wait loop
movlw 0xff
movwf level
swl
decfsz level
goto swl
return
pause ;big wait loop
movlw 0xff
movwf level
movlw 0x10
movwf level2
loop
decfsz level2,1
goto next
return
next decfsz level,1
goto next
goto loop
end
1995\12\06@205447
by
Rolan
|
many people have requested the code. It's been a while since I used
it. I hope this is the right program. The program is far from compact
or efficient, but it works (I think).
Remember to use a 16c84 and a 1 Mhz oscillator.
include <p16cxx.inc>
lo equ 0
hi equ 1
inuse equ 2
level equ 0ch
level2 equ 0dh
counter equ 0eh
durat equ 0fh
tmpout equ 10h
org 0x0000
goto init
org 0x0010
init
bsf status,rp0
movlw B'00000000'
movwf TRISB
movlw B'00011111'
movwf trisa
bcf status,rp0
movlw 0x01
movwf portb
movwf tmpout
begin ;main program
call chirp
call pause
goto begin
chirp ;make sound for dur
movlw 0x30
movwf durat
cycle bsf tmpout,0 ;on and offs
movfw tmpout
movwf portb
call smwait
bcf tmpout,0
movfw tmpout
movwf portb
call smwait
decfsz durat
return
goto cycle
smwait ;small wait loop
movlw 0xff
movwf level
swl
decfsz level
goto swl
return
pause ;big wait loop
movlw 0xff
movwf level
movlw 0x10
movwf level2
loop
decfsz level2,1
goto next
return
next decfsz level,1
goto next
goto loop
end
1995\12\06@222726
by
Rolan
|
many people have requested the code. It's been a while since I used
it. I hope this is the right program. The program is far from compact
or efficient, but it works (I think).
Remember to use a 16c84 and a 1 Mhz oscillator.
include <p16cxx.inc>
lo equ 0
hi equ 1
inuse equ 2
level equ 0ch
level2 equ 0dh
counter equ 0eh
durat equ 0fh
tmpout equ 10h
org 0x0000
goto init
org 0x0010
init
bsf status,rp0
movlw B'00000000'
movwf TRISB
movlw B'00011111'
movwf trisa
bcf status,rp0
movlw 0x01
movwf portb
movwf tmpout
begin ;main program
call chirp
call pause
goto begin
chirp ;make sound for dur
movlw 0x30
movwf durat
cycle bsf tmpout,0 ;on and offs
movfw tmpout
movwf portb
call smwait
bcf tmpout,0
movfw tmpout
movwf portb
call smwait
decfsz durat
return
goto cycle
smwait ;small wait loop
movlw 0xff
movwf level
swl
decfsz level
goto swl
return
pause ;big wait loop
movlw 0xff
movwf level
movlw 0x10
movwf level2
loop
decfsz level2,1
goto next
return
next decfsz level,1
goto next
goto loop
end
More... (looser matching)
- Last day of these posts
- In 1995
, 1996 only
- Today
- New search...