PDA

View Full Version : Going nuts here with a PIC16F688. What registers am I missing?



ShortBus
- 7th October 2009, 05:26
All I want to do is set every IO pin on the chip to digital out.


ADCON0 = 0 ' no analog >< digital conversions
ADCON1 = 0 ' no analog >< digital conversions
ANSEL = 0 ' no analog inputs
CMCON0 = 7 ' no comparators
TRISA = %0000100' all but RA3 (MCLR) is output
TRISC = 0 ' all outputs on port C

porta = 1
portc = 1
pause 1000
porta = 0
portc = 0

This should blink all of the attached LEDs, however only PORTA.0 and PORTC.0 go high and only one of them goes low when told to. I'm sure I'm forgetting to turn off a feature in a register (or something equally as simple). But I've been studying the datasheet for hours. Any hints? :-\

Jumper
- 7th October 2009, 05:31
That is just what you told the PIC to do.

porta = 1 ' 0000 0001
portc = 1 ' 0000 0001
pause 1000
porta = 0
portc = 0


porta = 255 ' 1111 1111
portc = 255 ' 1111 1111
pause 1000
porta = 0
portc = 0


First code sets bit 0 only, second code sets all bits for the port

ShortBus
- 7th October 2009, 16:17
That's what I get for attempting binary math after my bedtime. lol. Thanks for the help!