The internal oscillator doesn't automatically run at 8MHz. You have to
write to OSCCON to switch to 8MHz.
The default value of OSCCON frequency select bits is for 4MHz. See the
datasheet for the default value in this register at power up.
Also PULSOUT toggles the pin twice to produce your pulse, so the initial
state of the pin determins the polarity of the pulse.
You want a high-going pulse for your servo, so clear the pin before the
PULSOUT command.
See if this works.
Code:
@ DEVICE INTRC_OSC_NOCLKOUT, MCLR_OFF,WDT_OFF,PROTECT_OFF
DEFINE OSC 8
servo var PORTC.5
i var word
OSCCON = %01110000 ' Now it's going to run at 8MHz
PORTC.5 = 0 ' <-- make pin low before PULSOUT (toggles high then low)
TRISC.5 = 0 ' make pin an output
loop:
for i = 200 to 400
low servo
pulsout servo,i
pause 18
next i
goto loop
Bookmarks