void extrint (void) interrupt 0 // external Interrupt to detect the heart pulse
{
bt = tick; // number of ticks are picked
tick = 0; // reset for next counting
}
void timer0 (void) interrupt 1 using 1 // Timer 0 for one second time
{
TH0 = 0xdc; // The value is taken for Ssc/100 at crystal 11.0592MHz
sec100++; // It is incremented every Ssc/100 at crystal 11.0592MHz
tick++; // This variable counts the time period of incoming pulse in Sec/100
if (tick >= 3500)
{tick = 0;} // tick are limited to less than 255 for valid calculation
if (sec100 >= 100) // 1 sec = sec100 * 100
{
sec++;
sec100=0;
}
}
Can somebody explain me what the above code means and does. It was written for a 8051 microcontroller.
i got it from here http://www.zembedded.com/heart-rate-beats-meter-with-microcontroller-at89c51-based-heartbeat-monitor/
Very hard to tell without context. I guess following:
The timer0
interrupt routine is called every 100th of a second. There it increments the tick
counter which is reset to 0 as soon as it gets bigger than 3500. The sec
counter seems to be a second counter as it is incremented every 100th call to timer0
(which is called 100 times per second).
The extrint
seems to be called upon some external event. It just copies the actual value of tick
into bt
(presumably for some further processing) and resets tick
to 0.