PDA

View Full Version : Which is the frequency?



fabritio
- 14th February 2005, 15:34
Which is the frequency of this program?
I am using a pic16f876 with a 20Mhz Quartz...
Should it be same 20Mhz or not?
Thank you!!


i var word

TRISC = 0
PORTC = 0


inizia:

PORTC = %00000000
for i=0 to 255
PORTC = PORTC + %1
NEXT
goto inizia

end

fabritio
- 14th February 2005, 16:34
With the oscilloscope it comes out a frequency of 200 khz.
A change of state for the LSB every 5 microseconds.
Is it right?
How can i have 20 MHz as the crystal resonator???

Bruce
- 14th February 2005, 21:13
Try this. At 20MHz you should have a 500kHz signal on the pin used.


DEFINE OSC 20
TRISB.0 = 0

ASM
loop ; @ 20MHz 1us high + 1uS low
bsf portb,0 ; 200nS
goto $+1 ; 600nS
goto $+1 ; 1000nS high
bcf portb,0 ; 200nS
goto $+1 ; 600nS
goto loop ; 1000nS low
ENDASM

Nitro
- 2nd November 2005, 21:17
just bear in mind that the pic will divide whatever the clock frequency is by 4
ie: if you have a 20mhz crystal, it will perform funcions @5mhz or one operation per 1/4 millionths of a second.