Add
(see datasheet)Code:CMCON0 = 7
Add
(see datasheet)Code:CMCON0 = 7
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Hi JDM,
Your last sentence of the first paragraph-"I can only get the chip to run stable if I tie that pin to Vdd with a resistor."
If the pins are inputs you must pull them either hi or lo. You just can't leave them hanging there!
BobK
Isn't that the same as CMCON0 = %00000000, and isn't that the power up default values anyway? If you haven't noticed, I'm new at this :-) Thanks for any help.Originally Posted by paul borgmeier
About the clock issues, PBPs smallest value is 4mhz for the compiler. I have no choice on that one. The only impact for my program is my pause statements.
Also, I am setting the intoscio in the fuse configuration.
As far as having to tie inputs to ground or vdd, why is it only pin PORTA.2 that is giving me trouble?
I have a feeling it has to do with the external interrupt function on that pin, but it should be disabled by default no?
Thanks again all, your help is much appreciated.
CMCON0 = 0 ' Default (with most of PORTA = Analog)
CMCON0=7 ' all digital (or CMCON0 = %00000111)
Again, see datasheet (PORTA section, first highlighted box)
Let us know ...
Paul Borgmeier
Salt Lake City, UT
USA
__________________
Hi JDM,
It's your comments like "I can only get the chip to run stable if I tie that pin to Vdd with a resistor" that caused me to send you this comment. You give us clues to the mystery and it's up to us to guess what is going on. If you read enough posts on this forum you will see that many times the people on this forum ask for complete code listings and schematics to help us out.
Now you write "As far as having to tie inputs to ground or vdd, why is it only pin PORTA.2 that is giving me trouble?" I don't know what you have actually connected to your PIC. You are only talking about PortA.2. So when you comment about putting your finger on a pin or put a resistor to Vdd then the problem goes away, what do you think the response from us should be? You have gotten some good feedback from Paul, Sayzer, and myself as to the more common problems people have encountered with the types of comments you have made. Now it's your turn to help us out some more with a drawing of what you have going so we can help you more!
BobK
I am still having problems with my program. If I don't tie my inputs to ground, my program wont run properly! The problem is that I'm trying to sense a ground or "low" condition at that pin and using internal pullups.
My basic circuit is as follows: I am running 4 LEDs off of PORTC through NPN transistors. I am also running a PWM output.
I have 3 digital inputs that read a switch state as on or off. Pins are tied to ground through a 10k resistor. Press switch 1 on input 1 and LED1 on output 1 goes on (input pin drivin to +5V when switch closed). Nothing fancy, very simple logic.
My problem lies when I enable an input that is normally "high" through the weak pullups. The program does not run at all. If I configure that pin as an output, program runs fine.... There is no routines in the code that reference that pin either! So I'm pretty sure it's not my code...
What am I missing!!!
Here is my configuration:
OSCCON = %01100001 '4 Mhz
INTCON = %00000000 'disable interrupts
PIE1 = %00000000
CMCON0 = %00000111
ANSEL = %00000000 ' all digital I/O
TRISA = %11111111 ' input pins
TRISC = %11011111 ' input pins except pwm port
IOCA = %00000000
T2CON = %00000100 ' enable timer 2 for PWM and set prescaler to 0
CCPR1L = %00000000 'zero duty cycle
CCP1CON = %00001100 'enable PWM, active high
PR2 = 24 '0-100 duty cycle
Last edited by JDM160; - 4th November 2006 at 03:27.
Hi JDM160,
I have never used weak pull ups before, however; I do not see in you code where you enabled them. If I understand the data sheet correctly, and it is very possible I do not . . . WPUA=%00110111 should enable them on portA 0,1,2,4,5. with A3 configured automaticly if used as mclr and not available if configured as an I/O. The data sheet says weak pullups are disabled after power on reset.page 32.
Joe
Thank you everyone for trying to help me with my "problems." It turns out all my problems were due to a simple "while" statement. I'll be the first to admit it... I'm a moron.
Thank you so much for your help! Till next time LOL
Bookmarks