Seems to be an analog port related stuff...
let's open the 16F688 datasheet... mmm i see...
what about if you add...
at the top of your code?Code:ANSEL = 0
Seems to be an analog port related stuff...
let's open the 16F688 datasheet... mmm i see...
what about if you add...
at the top of your code?Code:ANSEL = 0
Last edited by mister_e; - 1st October 2007 at 22:08.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Yup, that solved the problem!
Now I realy must try to understand what ANSEL actually does ....
A BIG thanks again to Mister_E!
In that datasheet, ANSEL is not really well documented like most other PIC registers. You need to read between the line. Open the PDF and search for ANSEL, you'll find few hits.
Basically each bit of ANSEL is assigned to a ADC channel. Bit 0 to AN0, Bit 1 to AN1 and so on. POR value is 255, %11111111. If a specific bit is set, the corresponding channel will be set as analog, if it's clear, it's digital. ANSEL=0 will obviously set every channel to digital.
EDIT: erm... ok it's documented... Register 4-3, PDF page 36. It's just not in the ADC section... as it 'should be'. Why??? Because![]()
Last edited by mister_e; - 1st October 2007 at 22:48.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Yes, I also did a search for ANSEL in the datsheet and found nothing of much use.
Although it works in this example, I am still unclear why ANSEL has any effect on the behaviour of LEDs on PortC.3 and PortC.5 which are not configurable for analogue.
Miip! C.3 is also AN7...
In theory ANSEL.7=0 should also work.
PS: Read again post 4, i changed it while you replied.
Using a analog port as digital output will do weird things...
Last edited by mister_e; - 1st October 2007 at 22:56.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
A big thanks again Mister_e. Indeed PortC.3 is analogue too. Sorry I missed that! The datasheet could be much clearer on issues like this or, as Nomad says, such pearls of port configuration wisdom could be distilled into a HOW TO section of FAQs.
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Bookmarks