This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with a frequency counter

Hi, I'm trying to do a frecuency counter with an 89s52. I've made a long program, but it doesn't work well. In order to find the mistake, I've made this little program.

#include <stdio.h>
#include <reg52.h>

sbit SENSOR=P2^3;
void externa1 (void) interrupt 2
{EA=0;
SENSOR=~SENSOR;
EA=1;
}

void main (void)
{IT1=1;
IE=0x84;
while(1)
{}
}

A known signal (with a known period) interrupt in the INT1 line. The irq for INT1 toggle the bit 2 of port 3. The frequency of the signal in P2^3 must be the input frequency X 2. And here the problem:
With relative high frequencies (100-1Khz) I didn't have any problem, but with low frequencies it starts to oscillate.
Does anybody knows the solution for some kind of problems?
Thanx
Santiago

0