Currently I get values between 1800 and 400 for 'Value'. Whatever, don't hurry to answer this question because my current implementation works already. This is just for finetuning...
Currently I get values between 1800 and 400 for 'Value'. Whatever, don't hurry to answer this question because my current implementation works already. This is just for finetuning...
Last edited by selbstdual; - 18th February 2007 at 22:34.
Hi,
I would prefer using interrupts.
Your TIMER_ZERO is already a word variable. So on a timer zero interrupt you can just increment the HighByte of the variable and normally dump the TMR0 to the lowbyte. This would make a pseudo 16bit timer. On a comparator interrupt, get the readings. It should not be very difficult in ASM . By the way what is your clock frequency and your timer0 prescaler value ? If you are using a high prescale then Darrel's Instant Interrupt may work.
Regards
Sougata
Difference of time(MyMethod <-> Timer0) is the linchpin of this thread. I can't see a connection between your post and the main question.
This should not be measured. To calculate it, the timer0's speed is needed(How many cycles mean how many countings) and I want to know how fast my current implementation is(there is a number somewhere in the greatly written manual that states how much time these instructions take).
Then I get a comparison.
Last edited by selbstdual; - 21st February 2007 at 04:20.
As far as I understood you need to get the time elapsed between two states of your comparator. You can always get two intermediate readings. Get the difference between the readings. Even if prescale is 1:1 and you are using ASM interrupts then you know how may cycles you consumed to take a reading and asjust your results thus. This should give you far more accurate results than looping around. Cause you can just stop the timer at the comparator interrupt. Get the results. I suggested a pseudo 16bit because I don't know your possible timings between comparator changes. Thus timer zero may overflow. You did ask how to handle overflow!! With the additional Highbyte incrementing on overflow you do get a 16bit timer.
Regards
Sougata
Bookmarks