I use
setup_timer_2(T2_DIV_BY_1 , 255, 1);
and 4 MHZ crystal put the frequency is 30 hz and not 4KHZ which is the right frequence.I use PCM compiler and pic16F777.
What is the problem?????
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Thu May 03, 2007 11:00 am
Do some detective work. Study the ratios of the numbers.
It's running at 30 Hz, but you believe it should be 4000 Hz.
What is the ratio of these frequencies ? It's this:
Code:
30
---- = .0075
4000
Now multiply that ratio by the oscillator frequency that you believe
the PIC is running at:
Code:
.0075 * 4000000 = 30000
This implies that the true oscillator frequency is about 30 KHz.
Now look in the PIC data sheet, in oscillator section. Is there a
setting for the internal oscillator that is approximately 30 KHz ?
If so, your PIC is probably configured for that setting. How can
you change it to the desired setting of 4 MHz ? These are the
questions that you must answer.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum