Hi the code below counts heart rate pulses indefinitely. We would like to count how many heart rate pulses there are every ten seconds. Im not sure how to set up a timer to count the amount of pulses every ten seconds. We are using MikroC. Can you please help?
unsigned short T1_count = 0;
unsigned int temp_res;
int i;
void main() {
ANSEL = 0x04; // Configure AN2 pin as analog
TRISA = 0xFF; // PORTA is input
ANSELH = 0; // Configure other AN pins as digital I/O
TRISB = 0x3F; // Pins RB7, RB6 are outputs
TRISD = 0; // PORTD is output
TRISC = 0;
T1_count = 0;
do {
temp_res = ADC_Read(2); // Get 10-bit results of AD conversion
PORTD = temp_res; // Send lower 8 bits to PORTD
PORTB = temp_res >> 2; // Send 2 most significant bits to RB7, RB6
if (temp_res > 100){
delay_ms (100);
T1_count++;
PORTC = T1_count;}
} while(1);
}
unsigned short T1_count = 0;
unsigned int temp_res;
int i;
void main() {
ANSEL = 0x04; // Configure AN2 pin as analog
TRISA = 0xFF; // PORTA is input
ANSELH = 0; // Configure other AN pins as digital I/O
TRISB = 0x3F; // Pins RB7, RB6 are outputs
TRISD = 0; // PORTD is output
TRISC = 0;
T1_count = 0;
do {
temp_res = ADC_Read(2); // Get 10-bit results of AD conversion
PORTD = temp_res; // Send lower 8 bits to PORTD
PORTB = temp_res >> 2; // Send 2 most significant bits to RB7, RB6
if (temp_res > 100){
delay_ms (100);
T1_count++;
PORTC = T1_count;}
} while(1);
}