Confusion and possible bug on 16f876


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Melanie,

    I used to do it that way as well until reading the 16F mid-range ref
    manual.

    9.11 Initialization

    It is recommended that when initializing the port, the data latch
    (PORT register) should be initialized first, and then the data direction
    (TRIS register). This will eliminate a possible pin glitch, since the PORT
    data latch values power up in a random state.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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


    Did you find this post helpful? Yes | No

    Default

    Hi Bruce.

    Yeah... I read that too and disregarded it... didn't seem logical to start any I/O operation before you decided what the pin is going to be first. I normally follow the TRIS immediately with my pin initial state value... the school of thought being that the 1uS or so that a pin 'might' be in the wrong state at initialisation isn't going to do anything drastic. The most dangerous peripherals most folks could have are Relays, Contactors or SSR's - and they're just not going to react that fast. Further, there will be a number of clock cycles between physical Power-On and when the PIC actually wakes up and starts executing (kinda like me in the morning between the time the alarm clock goes off and my first cup of coffee!) and executes your first I/O Instruction and TRIS... now that is an indeterminate time anyway which is beyond our control during which the I/O pin will be high impedance - whatever you've got connected to that pin, and depending on the circuit, could float either way anyhow, so what's another uS between friends?

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