View Full Version : Newbie help: 16F690
mbw123
- 17th September 2006, 00:15
Please excuse me for this simple question. I am using a PICkit 2 with a 16F690 on the Low Pin Count Demo Board. I am trying to turn on an LED when I press a button. My code is below... the PIC dosn't seem to be responding to the button presses....Any help appreciated ( I am a major newbie, if you couldn't tell).
CODE:
main:
if PORTA.3 = 0 then pressed
goto main
pressed:
high PORTC.3
pause 250
low PORTC.3
pause 250
goto main
Darrel Taylor
- 17th September 2006, 00:25
Please excuse me for this simple answer.
PortA Doesn't Work
http://www.picbasic.co.uk/forum/showthread.php?t=561
Archangel
- 17th September 2006, 02:16
Please excuse me for this simple answer.
Eloquently put, Old Chap !
mbw123
- 17th September 2006, 03:02
TOUCHE!! Thanks for the help!
mbw123
- 18th September 2006, 00:55
OK, I followed your link. I followed the instructions but there is a compile error stating that "undefined symbol: CMCON". Here is my new code:
----------------------------
CMCON = 7
main:
if PORTA.3 = 1 then pressed
goto main
pressed:
high PORTC.3
pause 250
low PORTC.3
Pause 250
goto main
-----------------------------
Any help is appreciated!
-Mike
mister_e
- 18th September 2006, 03:46
Sure it will never work as there's no CMCON register for that PIC. BTW internal comparator are disabled at POR. Your problem is more with the ADCs.
ANSEL=0 ' disable ADCs
Darrel Taylor
- 18th September 2006, 03:52
Ok, well I guess that wasn't the best advice for the chip you are using.
On a 16F690, PORTA.3 is the MCLR/VPP pin, and it defaults to the "Master Clear" (MCLR). In order to use it as a digital input, MCLR must be disabled.
If using PM as the assembler then use this...
@ DEVICE MCLR_OFFor if using MPASM..
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFFBut you'll need to modify the 16F690.INC file in the PBP folder for it to work.
Also, PORTC.3 is multiplexed with the A/D converter, the Comparators, and the ECCP module. To use this pin as a digital output ...
ANSEL = 0
ANSELH = 0 ; for ANS8-11
The 16F690 is a very complex chip as far as PIC's go. And the datasheet is very confusing, to say the least. Wouldn't really recommend it for a first time user.
HTH,
P.S. Steve, I found the ANSELH from one of your previous posts. :)
mister_e
- 18th September 2006, 04:28
P.S. Steve, I found the ANSELH from one of your previous posts.
Hehe, was it the Ron Marcus Thread :D
It's an interesting PIC so far. I have few of them here but never found time to play with. mmm, this is why the Comparator latches reminded me something when surfing fast in the datasheet.
The 16F690 is a very complex chip as far as PIC's go. And the datasheet is very confusing, to say the least.
At least i'm not the only one to say that ;)
Darrel Taylor
- 18th September 2006, 04:54
>> Hehe, was it the Ron Marcus Thread
PBP & 16F690 bug?
http://www.picbasic.co.uk/forum/showthread.php?t=3952&highlight=16F690
That's the one!
Saved me from another hour or two of searching through that awful datasheet.
Thanks!
<br>
mbw123
- 18th September 2006, 14:59
Should I just use a different pin for the button? Would that make it easier than disabling the MCLR? I could just use "ANSEL = 0" and use another PORTA port. Thanks for responses!
-Mike
mbw123
- 18th September 2006, 16:35
I also have a PIC16F628A...should I use that instead of the PIC16F690 because of the complexity issues (I already have a programmer adapter for it)? I would still use the "ANSEL = 0" line; will it work?
-Mike
Darrel Taylor
- 18th September 2006, 17:53
I think think the 628A will be easier for you, as long as you won't be needing the A/D module in the future. It doesn't have one. Would have been easier for me too, since I changed my previous post about 10 times. :)
But you'll need CMCON = 7 for it's analog pins.
However, like you suggested, you could use another pin and ANSEL = 0 and it should work fine with the 690. For now.
<br>
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.