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


Results 1 to 24 of 24

Threaded View

  1. #19
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

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

    Today I checked your code. Changed IESO in the configs and a bit in OSCCON which was read only.

    Works just fine. Only thing is that LED on portb.7 is interfering with the programming and causing programming errors!

    Besides that everything works just fine on the F887 chip at 8MHz.

    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_OFF               ; 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
    #endconfig
    
    OSCCON=%01110001  'SET INTOSC TO 8MHZ
    
    ANSEL = %00000000
    ANSELH = %00000000 'disable ADC
    
    
    TRISC=%00000000 'set PORTC as output all
    TRISD=%00000000 'set PORTD as output all
    TRISB=%00000000 'set PORTB as output all
    TRISA=%00000001 'set PORTA 0 as input, others as output
    TRISE=%00000000 'same here
    BUZ var PORTB.7
    BUTN var PORTA.0 
    
    
    
    DEFINE OSC 8   'OSC SPEED
    'turn off all digits
    
    
    PORTA=0: PORTB=0: PORTC=0: PORTD=0 : PORTE=0 'turn off all outputs
    
    CYCLER:
    if BUTN=0 then
    high BUZ
    pause 100
    low BUZ
    pause 100
    endif
    goto CYCLER
    
    end
    I did a short video that shows a working state of the circuit on a PICdem2 Plus board. The PortA.0 is shorted by the yellow wire to ground.



    Ioannis
    Last edited by Ioannis; - 22nd April 2020 at 21:51. Reason: Video addition

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 : 1

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