Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/07/00 23:26
Read: times


 
#1714 - Timer 0 to get frequency
I need help with a routing to test for frequency. The original routine came from app note AN426. I modified the code some but the requirement is the same; determine the freq. of an input signal; in my case 5-14000hz. The problem is that the timer values vary
so much at 10000hz it may be 9890 or 10140.
How do I get consistent readings?
Thanks for ANY and ALL help.....Bill
code attached.


meas_st1: ; start here to test

mov tmod,#00000001B ; timer 0 16bit
clr tr0 ; halt timer

mov tl0,#
mov th0,#0
mov r3,#0 ; clear timer 3rd byte
clr c
mov ie,#082h ; and timer 0 interrupt
w20:
jc gzs ; jump if r3 > 08
jb p3.4,w20 ; wait for t0 inputlow
w21:
jc gzs ; jump if r3 > 08
jnb p3.4,w21 ; wait for t0 input high

mov r3,#0 ; clear timer 3rd byte
setb tr0 ; start timer

w22:
jc gzs ; jump if time up (carry set)
jb p3.4,w22 ; wait for t0 low
w23:
jc gzs ; jump if time up (carry set)
jnb p3.4,w23 ; wait for t0 high again

clr tr0 ; halt timer
mov ie,#0A0h ;disable timer interrupts

jmp per_calc ; goto calculate freq.

gzs:
clr tr0 ; halt timer
mov ie,#0A0h ; disable interrupts
jmp meas_st1 ; repeat if zero



List of 3 messages in thread
TopicAuthorDate
Timer 0 to get frequency            01/01/70 00:00      
RE: Timer 0 to get frequency            01/01/70 00:00      
RE: Timer 0 to get frequency            01/01/70 00:00      

Back to Subject List