16f684 Porta.2 Instability


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    JDM160's Avatar
    JDM160 Guest


    Did you find this post helpful? Yes | No

    Unhappy

    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.

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default weak pull ups

    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

  3. #3
    JDM160's Avatar
    JDM160 Guest


    Did you find this post helpful? Yes | No

    Default

    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

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    One more reason why you always should post your whole code first
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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