We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I was thinking whether its feasible to use a 8-bit counter with auto-reload to capture the number of peaks detected within 100ms.
"how do i call a C function from asm?"
http://www.keil.com/support/man/docs/c51/c51_ap_ctoasm.htm
I see... thanks.. I just found out that my ocillator is running a 2Mhz. Which is 6us per tick. Do i have to add an external crystal of 1Khz to get 1ms per tick?
Wrong.. shld be 12Khz crystal... Isit available in the market?
"should be 12Khz crystal"
No. That should be 12kHz - the upper & lower case matter - see www.8052.com/.../read.phtml
I see... isit available in the market? Because all i see is in Mhz...
If you have hardware that: - always divides the crystal frequency with 12 - and there is no prescaler support - and you need the timer to tick at 1ms then you would need a 12kHz crystal.
However, most timers have a large set of options for specifying a frequency, and for setting up how it is expected to be run. That may include support for different clock sources, use of prescalers etc.
If you want to generate interrupts everh 1ms, then you figure out how many ticks the timer need to tick until 1ms has passed, given the frequency that your timer steps with.
In this case, you are going to measure the time between heart beats. You only need a calibrated time. It isn't important if your timing manges to measure time with higher resolution than required, as long as you make sure that you know about any timer overflows.
If the timer doesn't tick at 1ms, then it's enough to know exactly what speed it runs in, to allow you to multiply/divide the results you get with whatever scale factor is needed to convert the time into seconds, milliseconds or whatever you want.
As suggested earlier, measure he time it takes to capture a fixed number of pulse events. If you use the capture registers to pick up the values from the free-running timer, all you need to do is figure out exactly how many ticks the timer has stepped during these heartbeat intervals. If it ticks at 1MHz, then obviously every tick is worth 1us. If it ticks at 200kHz, then every tick is worth 5us, ...
Use whatever prescaler options you have to initialize the timer, and use that precision for the timing.
One question. I know that my hardware always divide the crystal frequency by 12. But what do you mean by prescaler support?
Isit a function where you can choose the frequency that you want to run at?