16F887 - PORT pins interfere with each other when set high/low


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default Re: 16F887 - PORT pins interfere with each other when set high/low

    OK. Lets stick on your first code that looks OK to me.

    What is connected to your buzzer output? Can you connect only a LED with a resistor for testing purposes?

    And I would also consider having decoupling capacitors the power rails, as close as possible to the PIC power pins.

    Maybe you have an interference of the buzzer if it is electromagnetic?

    Ioannis

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: 16F887 - PORT pins interfere with each other when set high/low

    Hey CuriousOne, Where is the ENDIF to finish the "if BUTN=0 then" statement?
    Dave Purola,
    N8NTA
    EN82fn

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default Re: 16F887 - PORT pins interfere with each other when set high/low

    Assuming we refer to the first program, the ENDIF it there at the end.

    On the snippets it is missing, but I doubt that this can compile anyway.

    Ioannis

  4. #4
    Join Date
    Apr 2014
    Location
    OK
    Posts
    557


    Did you find this post helpful? Yes | No

    Default Re: 16F887 - PORT pins interfere with each other when set high/low

    I don't use this particular Model T PIC, so I reserve the right to miss some quirks. Here are things I would check:

    1. You don't list your CONFIGs, but try disabling the WDT. It could be resetting on you.
    2. Try enabling CLKOUT and verify oscillator. On one project I did years ago, I had the crystal too far from the OSC pins and it would work for a few seconds then Peter out.
    3. Not sure which PORT PIN is MCLR, but you only have one Input in your TRISx Registers. MCLR should be a "1" (even though it probably defaults to Input Only). Don't forget the pull-up resistor.
    4. Make sure there are no other default settings triggering things unexpectedly (like Comparator or something).
    5. I think you already tried removing the PICkit3 programmer before trying the code. Using PORTB.7 probably ties into a PICkit3 programming pin.

    Some food for thought, things to try. Hope it helps.

  5. #5
    Join Date
    Feb 2013
    Posts
    1,132


    Did you find this post helpful? Yes | No

    Default Re: 16F887 - PORT pins interfere with each other when set high/low

    Code:
    #CONFIG
    cfg1 = _INTRC_OSC_NOCLKOUT    ; INTOSCIO oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
    cfg1&= _WDT_ON                ; WDT enabled
    cfg1&= _PWRTE_OFF             ; PWRT disabled
    cfg1&= _MCLRE_OFF             ; RE3/MCLR pin function is digital input, MCLR internally tied to VDD
    cfg1&= _CP_OFF                ; Program memory code protection is disabled
    cfg1&= _CPD_OFF               ; Data memory code protection is disabled
    cfg1&= _BOR_OFF               ; BOR disabled
    cfg1&= _IESO_ON               ; Internal/External Switchover mode is enabled
    cfg1&= _FCMEN_ON              ; Fail-Safe Clock Monitor is enabled
    cfg1&= _LVP_OFF               ; RB3 pin has digital I/O, HV on MCLR must be used for programming
    cfg1&= _DEBUG_OFF             ; In-Circuit Debugger disabled, RB6/ICSPCLK and RB7/ICSPDAT are general purpose I/O pins
      __CONFIG _CONFIG1, cfg1
    
    
    cfg2 = _BOR40V                ; Brown-out Reset set to 4.0V
    cfg2&= _WRT_OFF               ; Write protection off
      __CONFIG _CONFIG2, cfg2

  6. #6
    Join Date
    Feb 2013
    Posts
    1,132


    Did you find this post helpful? Yes | No

    Default Re: 16F887 - PORT pins interfere with each other when set high/low

    Ok here are answers.

    1. PORTB.7 is connected via 10K resistor to MPSA42 transistor, which drives buzzer.
    2. I tried replacing it with led, different buzzer, no difference. Sometimes it works, sometimes it does not.
    3. I've used another PIC16F887 - no change.
    4. Of course I've tried disconnecting pickit 3 - no difference.
    5. This problem ONLY occurs with PORTB.7 as output and PORTA.0 as input. Say if I don't query PORTA.0 for input and just make PORTB.7 high/low from the code, it works fine.
    6. All remaining ports (except PORTA 1 & 2 which are connected to DS3231) are connected via 10K resistors to MPSA42 transistors, which drive nixie tube cathodes and work fine.
    7. MCLR, WDT and others are disabled, as you can see from above config.

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,139


    Did you find this post helpful? Yes | No

    Default Re: 16F887 - PORT pins interfere with each other when set high/low

    WDT is ON on your code but I doubt that this is causing troubles as the compiler takes care of this.

    MCLR: is it tied to Vss or Vdd?

    Ioannis
    Last edited by Ioannis; - 22nd April 2020 at 13:41.

Similar Threads

  1. Replies: 10
    Last Post: - 14th April 2014, 20:47
  2. 16F887 PORTC.7 high
    By Neosec in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 31st March 2013, 22:39
  3. Help in trying to set pins functions
    By MinesCoffee in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 8th December 2012, 18:03
  4. PortB pins will not initialize LOW, only HIGH?
    By ronbowalker in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th December 2009, 19:27
  5. Replies: 0
    Last Post: - 25th May 2005, 10:35

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