Hi,
As have been said, and to add a bit: HIGH/LOW are commands which not only set the pin HIGH and LOW, it also makes the pin an output even if it already IS an output. Your code, compiled for a 12F683 (yes, it's different when compiled for other targets) results in the following ASM output:
Code:
_Cycle
bsf GPIO, 000h
bsf STATUS, RP0
bcf ((GPIO) + 80h), 000h
bcf STATUS, RP0
bcf GPIO, 000h
bsf STATUS, RP0
bcf ((GPIO) + 80h), 000h
bcf STATUS, RP0
goto _Cycle
All instructions takes one cycle except the GOTO which takes two and if you count the number of cycles you'll get 10. With the PIC running at 4MHz each instruction cycles takes 1us so the loop takes 10us to complete which matches your 100kHz measurement exactly.
Now, if you'd do something like this instead:
Code:
TRISIO.0 = 0
Cycle:
GPIO.0 = 1
GPIO.0 = 0
Goto Cycle
The resulting ASM code looks like this:
Code:
.
bsf STATUS, RP0
bcf TRISIO, 000h
bcf STATUS, RP0
_Cycle
bsf GPIO, 000h
bcf GPIO, 000h
goto _Cycle
Now the actual loop is only 4 cycles instead of 10 so you'd get 250kHz instead of 100kHz when operating the PIC at 4MHz - quite a difference.
/Henrik.
Bookmarks