Power up reset


Closed Thread
Results 1 to 7 of 7

Thread: Power up reset

Hybrid View

  1. #1
    Join Date
    Nov 2009
    Posts
    5

    Default Power up reset

    Hello,

    I am programing a PIC16F886 with inputs on Ports A and C, and outputs on Port B. I am trying to figure out how to keep the output form going high during power up. I have found in the PIC data sheets where it talks about the different resets; Power-On, MCLR, BOR, etc. Which you can set using register CONFIG1 and CONFIG2. I have not been able determine how to set these using software; though I have tried to set them using MPLAB under the configure menu. I have enabled MCLR, BOR, and Time-ON Delay, but the output still ramdomly turn on.

    Could I get some recommendations as to how to keep the output low during power-up?

    Thanks,
    Shawn

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi,

    During power up ...

    all pins are INPUTS ( say floating ! ) ... till you turn them to outputs.

    So ...

    1) place some pullup or pulldown ( to suit your application ) resistors to fix the outputs ( may be inputs too, depends on circuitry ahead ... ) levels while they are " uncontrolled "

    2) program output and input levels required ( PORTx = % 11001010 i.e )

    3) THEN program inputs and outputs ( TRISx = % 00110110 i.e )

    This way ... outputs are fully under control ... Even if Pic is taken off from its socket !!!


    Alain
    Last edited by Acetronics2; - 24th November 2009 at 14:41.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Nov 2009
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Hi Acetronics,

    My current port configuration setup:

    '*** PIC16F886 CONFIGURATION *************************

    OSCCON = %01100000

    ANSEL = %00000011
    TRISA = %11111111

    ANSELH = %00000000
    TRISB = %00000000

    TRISC = %11111111

    So I should look at adding PORTx = 0 before the TRISx register to clear the port register?

    Is this good programming practice (newbe question)?

    I have pull-down resistors on the input but not on the outputs, so I can look at adding those.

  4. #4
    Join Date
    Jul 2005
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ShawnB View Post
    So I should look at adding PORTx = 0 before the TRISx register to clear the port register?

    Is this good programming practice (newbe question)?

    I have pull-down resistors on the input but not on the outputs, so I can look at adding those.
    By all means clear the ports before changing TRISx. The MC data sheet on this part defines the port pins as UNDEFINED after power-up.

    It is definitely good programming practice, even on parts where the data sheet says the pins should be in the state you think you want.

    Output pull downs are probably the way to go, just make sure you have enough current to drive them, and they take enough current to actually pull down the input they drive.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by ShawnB View Post

    So I should look at adding PORTx = 0 before the TRISx register to clear the port register?

    Is this good programming practice (newbe question)?

    I have pull-down resistors on the input but not on the outputs, so I can look at adding those.
    Hi, Shawn

    Clearing PORTx is not the way ...

    but you must set PORTx to get a SAFE and KNOWN state at your Program start ...

    so, if you have a PNP transistor driving something ... it's driving port initial state MUST be a "1" state with a Pullup resistor ... for the transistor NOT to conduct.

    I already had the "gag" with an electronic ignition :

    @ Power UP the guy had programmed a CLEAR Port.

    and after he had preset the Port pin to 1 ... as the transistor driven was a PNP ...


    so, When turning the contact Key ... often an explosion occured in a cylinder : not so good , hey ???

    The Good practice is to ensure a SAFE initial state ... processor placed or not.

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Nov 2009
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Acetronics,

    I made the changes you recommended and that appears to have corrected the problem.

    I do have a questions regarding how the MCLR and BOR fuction work. If either or both are enabled, what happens on power-on? In the data sheets it appears to me that it sets all the ports to 0. Where on a power-on leaves the ports unchanged. Does one have priority over the others or are there all reseting at the same time?

    Thanks,
    Shawn

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Wink

    Hi, Shawn

    MCLR is the " Manual reset " pin

    BOR is the " Voltage Supply weakness " reset ... to avoid unwanted behaviour.


    Now ...

    MCLR has "absolute priority" over everything ...


    Remember all ports are left inputs @ Power-Up and nothing is sure until you write what you want to get ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. Battery powered applications
    By NavMicroSystems in forum Off Topic
    Replies: 7
    Last Post: - 22nd June 2009, 07:12
  3. Pic getting part power from Analog Port
    By ShaneMichael in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 22nd April 2009, 10:34
  4. PIC power backup with "super capacitor"
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 24th January 2007, 23:51
  5. 12 Servo's together does not seem to work, Power problem
    By macx75 in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 13th December 2006, 19:30

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