you can do something like that too. BUT you must consider the time you get out of counting and do the math with your variable + return to the counting stuff and such. And more if you're using PAUSE 1000, it will never interrupt before the PAUSE statement has finish. That come bigger and bigger then?!?!
To do that, in software, you'll need at least 1 timer and 1 counter. Let's say we gonna use TIMER1 as 1 sec time-base and TIMER0 as counter. See datasheet for that.
OR More simple, use a external 1sec time-base and do the count untill you're time-base tell you to stop.
IMO, the easyest way is to begin with a sampling time of 1ms, checking if there's any result, if not, redo with a higher sampling time, testing the overflow and result if it's not what you expect, redo with a higher sampling time, testing the overflow and result .... utill you have 1Sec sampling time or expected result.
so it could be as propose 1ms, 10ms, 100ms, 1Sec
don't forget timer will gives count a max of 65536. This is why if your sampling time is 1 sec = max frequency 65.536 KHz.
frequency = pulses / secondes
where 65.536 KHZ is 65536 pulses / secondes.
Last edited by mister_e; - 27th January 2005 at 20:48.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks