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.
You can use a high-speed counter and capture the time of a pulse. After you have captured enough pulses, you know (from the running counter) how long time has passed according to the counter tick frequency and number of ticks.
Oh. But how do you use programming to get the time between 2 heartbeats?
If so, how can i use programming to measure the time between the 2 heartbeats?
You will need to set up one time to generate your "base" clock (1 millisecond ticks). Then you use either an interrupt or polling (heart rates are slow enough to allow this) to wait for the heartbeats.
I see... So I'm using a integrated 16-bit counter with capture... Thanks...
"A high-to-low transition on the T2EX input pin causes the 16-bit value in Timer 2 (TH2, TL2) to be loaded into the capture registers (RCAP2H, RCAP2L)."
This means that my counter can only capture the values of TH2 and TL2? How do i capture the time than?
Does it matter if you measure the time between two low-to-high or two high-to-low flanks? Are you expecting them to come at different frequencies???
Note that each tick of the timer do represent real time. Hence, the capture represents a specific position on the time scale. When you have received a capture, remember the time and rearm for a new capture.
I see. So i have to run the timer for some time(lets say 3 sec) and whenever theres a high-to-low transition, the timer will capture the high-to-low transition and stores the position in TL2 and TH2?
And from TH2 and TL2, how do i find out the time?
"to be loaded into the capture registers (RCAP2H, RCAP2L"
If you had a normal clock ticking one step every ms, and you have the ability to now and then capture a value - how would you then figure out how long time have passed?
I'll use the bit "C/T2" and uses the system clock divided by 12.
How do i set my timer to one milliseconds ticks?
My processor is 25Mhz...
So i use the formula:
1/12 * 25 = 2.083us
I know from this that each step from the timer is 2.083us.
I know how to configure the timer already. Whenever theres is a pulse, an interrupts will occurs and copy the values of RCAP2H and RCAP2L. But i do not know how to make it such that when it recorded 4 pulses, it will stop and later loop back again. I know i have to use the DJNZ instruction, but where do i put the DJNZ instruction?
Can someone pls advice me on what to do?
If you are not comfortable with assembler, maybe you should do it in C.
Yea.. i was thinking of doint the math routine in C. But how do i call a C function from asm?
"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?