Can't keep a pin low


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189

    Default Can't keep a pin low

    I'm using a 12F629

    I have set all my ports to either input or output and turned off the comparitor.

    I have a PNP transistor on GPIO.4 and a LED for testing the state of the pin.

    The program is set to start with GPIO.4 LOW which is seems to do - my LED is lit.

    The problem crops up when I use a button to supply an input to any one of three other ports OR put another port HIGH to play a sound on a transducer.

    None of the subroutines address GPIO.4 in any way yet it is being switched to HIGH and not staying in the low state I'm looking for.

    Reading through the datasheet I didn't see anything on GPIO.4 that should suggest it should behave any way other than a general output with the configuration I have set up however I will admit to the datasheets being quite a bit over my head.

    So what is causing the other ports to affect my pin from staying low?

    Thanks.

    Bart

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Take your pick...

    Bad code, or
    Bad PIC, or
    Bad Circuit.

    Since all pins operate pretty much independently, you either have a short between it and an adjacent pin somewhere, or you have a dud PIC, or your code is flawed (which includes not initialising the PIC properly or resetting the PIC in some way into it's initial power-up state). Are you perhaps using some command which is not valid for the 12 series PICs?

  3. #3
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189


    Did you find this post helpful? Yes | No

    Default

    Hmmm, can there be a fourth choice?

    I swapped PICs with no change
    I've triple checked all the connections on the breadboard

    That leaves a code problem.

    Here is the first part of that:

    @ DEVICE pic12F629, INTRC_OSC_NOCLKOUT ' Internal Oscillator
    @ DEVICE pic12F629, WDT_ON ' Enable watch dog timer
    @ DEVICE pic12F629, PWRT_ON ' Enable power up timer
    @ DEVICE pic12F629, MCLR_ON ' Enable MCLR pin

    Define OSCCAL_1K 1 ' Oscillator calibration

    TRISIO = %11101011 ' turn all I/O to input except GPIO.2 and GPIO.4

    CMCON = 7 ' Disable analog comparator

    Which is working for all other input and output.

    As far as I can tell there is no command that is not allowed. It is all basic stuff like driving a buzzer based on buttons pressed - really nothing fancy. A single input on any of the other lines that does nothing but make a beep seems to be flipping that pin - and that buzzer is on port 2.

    I'll keep going through the code.

    Thanks.

    Bart

    I just tried something simple and discovered that when my port 2 goes HIGH, port 4 is going HIGH at the same time, but it will not switch back when port 2 goes LOW again.

    Does that suggest anything?
    Last edited by bartman; - 2nd January 2006 at 16:06.

  4. #4
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Describe how do you drive the LED and the buzzer.
    Post a small schematic with components type and values.

    - Voltage on the VDD pin if the PIC.
    - Voltage on the emitter of the transistor.
    - Type of transistor.
    - Type of buzzer.


    Also post a complete small program showing the problem.

    Best regards,

    Luciano

  5. #5
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189


    Did you find this post helpful? Yes | No

    Default

    I can give you some of this, but since it's only something I "fiddle with" I don't have anyway right now to provide all info.

    I'm running it on 3 volts
    Don't have emitter voltage, but it can drive a sound board that runs on 3-4 volts
    PNP common type 2N4403
    Buzzer is your run of the mill transducer driven from PIN through cap

    I don't have a "small" version of the program.

    If the line says GPIO.4 = 0 the LED (or the sound board I have on it) works properly.
    If I then use GPIO.2 = 1 or I use SOUND GPIO.2 [whatever value] then port 4 goes HIGH instantely.

    Switching port 2 back to low does NOT reset port 4 to low so it just works one way.

    The idea is that there are three buttons that play different combinations of the SOUND command depending on how they are pressed. With each press there is also a confirmation beep. At the same time there is going to be a sound module working on its own. The confirmation beeps should play and have no effect on the sound module.

    The sound module power runs through the transistor which is acting just like a switch that can turn the sound module on or off depending on the value of port 4.

    I removed SOUND command that would play the confirmation beep and tried it that way. Without that port 2 address happening the PIC would turn the sound module on or off with the button presses just as it should. That suggested to me that port 2 addressing was causing the problem so I then put a HIGH 2 command in place of the sound command and tried that. Sure enough, the second port 2 went high port 4 did as well.

    I will work on a version of the program that is short that I can post here. I'll have to remove a lot to boil it down then I will post that.

    Thanks.

    Bart

  6. #6
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    237


    Did you find this post helpful? Yes | No

    Post

    Measure the voltage on GPIO.4 when it's low. It MUST be a low voltage(below 1V), if not you will have problems just like this. My guess is that you have a short on the base resistor to the PNP or forgotten it completely.

Similar Threads

  1. Is this a K Type sensor?
    By jessey in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 21st November 2009, 13:55
  2. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 15:23
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07
  5. 4-line LCD Help - using PortA instead of B
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 31st March 2005, 03:14

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