16f684 Porta.2 Instability


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    JDM160's Avatar
    JDM160 Guest

    Default 16f684 Porta.2 Instability

    I'm having a problem with PORTA.2 on a 16F684. Even though I have disabled all external interrupts and set everything to digital I/O, I can not run portA.2 as an I/O port. As a matter of fact, any change in voltage on that pin causes erratic behavior and an apparent "reset" of the chip. By change in voltage, I mean as little as touching the pin. I can only get the chip to run stable if I tie that pin to Vdd with a resistor.

    Here are my program configs:

    '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    include "modedefs.bas"

    DEFINE OSC 4

    OSCCON = %01010000 '2 Mhz

    ANSEL = %00000000 ' all digital I/O

    TRISA = %11111111 ' input pins
    TRISC = %11011111 ' input pins except pwm port

    T2CON = %00000110 ' enable timer 2 for PWM and set prescaler to 16

    CCPR1L = %00000000 'zero duty cycle
    CCP1CON = %00001100 'enable PWM, active high

    PR2 = 24 '0-100 duty cycle
    '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

    Have i missed a necessary configuration that will disable any peripheral components that can cause this instability? Thanks in advance!

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Hi JDM160,

    Couple of things.

    1. Your DEFINE is 4 MHz but you set your PIC to 2 MHz. You are telling Complier that you are going to use 4Mhz operation, but the PIC will be running at 2 Mhz.

    2. Separately from Item 1 above, check your OSCCON.0 (bit0).
    OSCCON.0=1, Internal oscillator is used for system clock.
    OSCCON.0=0, Clock source defined by FOSC<2:0> of the CONFIG register.

    --------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Add
    Code:
    CMCON0 = 7
    (see datasheet)
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  4. #4
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    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

  5. #5
    JDM160's Avatar
    JDM160 Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier
    Add
    Code:
    CMCON0 = 7
    (see datasheet)
    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.

    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.

  6. #6
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    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
    __________________

  7. #7
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    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

Similar Threads

  1. 16F684 Basic Functionality
    By munromh in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 30th September 2009, 20:28
  2. 16F684 and RA2
    By GoldStar in forum General
    Replies: 1
    Last Post: - 21st May 2009, 07:29
  3. ICSP and 16F684
    By onaclov2000 in forum Schematics
    Replies: 4
    Last Post: - 5th March 2009, 17:31
  4. help with HPWM on 16f684
    By kimvellore in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 23rd May 2006, 08:05
  5. Help Quick Need to make code smaller
    By Programmednew in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 25th January 2005, 03:46

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts