PDA

View Full Version : Why doesn't this servo code work?



artswan
- 5th December 2009, 16:33
I am trying to use this simple servo code on a 16F684 using portc.1. What am I missing? Why doesn't it work? All that happens is the servo twitches when downloading the hex file, then that's all.

OSCCON = %01100001 '4 Mhz on internal osc

TRISC = %00000000
PORTC = %00000000

x var byte
y var byte

main:

for x = 0 to 50
pulsout portc.1, 75
pause 20
next x

pause 2000

for y = 0 to 50
pulsout portc.1, 175
pause 20
next y

pause 2000

goto main

end

Acetronics2
- 5th December 2009, 17:09
Hi,

The answer is in your Datasheet ...

PortC1 is shared with the on chip ADC ... so you must tell the chip you want to use it as a DIGITAL pin ...

BTW ... Comparator also shares this pin ... soooo ...

Two datasheet sections to review ...

Alain

mackrackit
- 5th December 2009, 19:51
Read this also
http://www.picbasic.co.uk/forum/showthread.php?t=561

artswan
- 5th December 2009, 22:18
Thanks! That helps a lot. I use a lot of different PIC chips
and it's been a long while since I used a 684. I thought I
had remembered all the details.

:)




Hi,

The answer is in your Datasheet ...

PortC1 is shared with the on chip ADC ... so you must tell the chip you want to use it as a DIGITAL pin ...

BTW ... Comparator also shares this pin ... soooo ...

Two datasheet sections to review ...

Alain