PortB pins will not initialize LOW, only HIGH?


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2009
    Location
    Austin, Texas
    Posts
    15

    Default PortB pins will not initialize LOW, only HIGH?

    I am trying to initialize a PIC16F819 and it will not take the PORTB pins to a LOW setting on initialization. It does PORTA just fine, and it does both TRISA and TRISB settings correctly. What is it I am missing here?

    'CODE:
    'Initialize Inputs/Outputs
    TRISA = %01110100
    TRISB = %01000000
    'Initialized Highs/Lows
    PORTA = %10000001
    PORTB = %00000000

    I have also tried to use the (PORTB.0 = 0) way, and it too does not work.
    Neither does (LOW PORTB.0).

    Never had this problem with any of the other chips I have used.

    Here is the .INC file info for MPASM......
    __CONFIG _INTRC_IO & _WDT_OFF & _PWRTE_OFF & _LVP_OFF & _MCLR_OFF & _BODEN_OFF & _DEBUG_OFF
    Last edited by ronbowalker; - 7th December 2009 at 14:44. Reason: Added Info on .INC file

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ronbowalker View Post
    I am trying to initialize a PIC16F819 and it will not take the PORTB pins to a LOW setting on initialization. It does PORTA just fine, and it does both TRISA and TRISB settings correctly. What is it I am missing here?

    'CODE:
    'Initialize Inputs/Outputs
    TRISA = %01110100
    TRISB = %01000000
    'Initialized Highs/Lows
    PORTA = %10000001
    PORTB = %00000000

    I have also tried to use the (PORTB.0 = 0) way, and it too does not work.
    Neither does (LOW PORTB.0).

    Never had this problem with any of the other chips I have used.

    Here is the .INC file info for MPASM......
    __CONFIG _INTRC_IO & _WDT_OFF & _PWRTE_OFF & _LVP_OFF & _MCLR_OFF & _BODEN_OFF & _DEBUG_OFF
    Hello ronbowalker,
    enable the port latches Before the tris registers. Disable the other functions on these port pins especially any analog functions like CCP. CCP1CON = 0 SSPCON.5 = 0 ' disables Syncro. serial port

    "When enabling peripheral functions, care should be
    taken in defining TRIS bits for each PORTB pin. Some
    peripherals override the TRIS bit to make a pin an output,
    while other peripherals override the TRIS bit to
    make a pin an input. Since the TRIS bit override is in
    effect while the peripheral is enabled, read-modifywrite
    instructions (BSF, BCF, XORWF) with TRISB as
    the destination should be avoided. The user should
    refer to the corresponding peripheral section for the
    correct TRIS bit settings."
    Last edited by Archangel; - 8th December 2009 at 03:04.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Hi Ronbowalker. Use this header at the top of your program. I have never had a problem with it.

    OSCCON = $60 'sets int osc to 4mhz
    adcon1 = 7 ' set inputs to digital. adcin command will convert to analog
    @ DEVICE MCLR_ON, INTRC_OSC, WDT_ON, LVP_OFF, BOD_OFF, PWRT_ON, PROTECT_ON

    Then add your program code.

Similar Threads

  1. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52
  2. SERIN MIDI out of Synch?
    By jncortes in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 9th June 2009, 20:08
  3. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 15:23
  4. Someone help me to simplify this
    By thrix in forum General
    Replies: 4
    Last Post: - 21st February 2004, 05:01
  5. Help wanted..
    By thrix in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 17th February 2004, 23:44

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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