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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/05/02 19:29
Read: times


 
#23967 - RE: count pulses within a limited time
Assuming I got your requirement straight...
Use one timer (or both) to generate the 3 second interval. You dont need a second timer, since the total time for all pulses wil always be 3 sec. So u can get the average time as:
avg_time=3sec/pulsecount

But its going to be tricky:
I suggest u use p3.2 instead of p3.4, as that can be used as an interrupt to measure the number of pulses in 3 sec

here's the oversimplified pseudo code I think will do the job:

org 0000h
ljmp start

T0_Int_Vector:
mov pulsecount, #00h
setb calc_bit
;reload timer values
;resart timer
reti;

EX0_int_Vector:
inc pulsecount
reti;

start:
;initialize stack
;enable interrupts
;load timer values
;start T0

main_loop:
do_other_stuff()
jnb calc_bit,main_loop

clr calc_bit
R2= 60*3/pulsecount
ljmp main_loop

I am guessing the calculations will involve 32-bit math and some sort of floating point formatting. I think that will be the more difficult part, rather than the interrupts and the timers...

Correct me if I am wrong

kundi



List of 2 messages in thread
TopicAuthorDate
count pulses within a limited time            01/01/70 00:00      
RE: count pulses within a limited time            01/01/70 00:00      

Back to Subject List