Shop OBEX P1 Docs P2 Docs Learn Events
TRIS — Parallax Forums

TRIS

BebopALotBebopALot Posts: 79
edited 2006-02-07 22:13 in General Discussion
Ok, I see. So you can set the HI or LOW of a pin only when the mode $0f TRIS register is set to output. Since it is set to output by default, there is no need to access TRIS for typical logic state settings of the pins. You can set the PINS with MOV commands. If the PIN changes I/O status to input (for whatever reason) and you wanted it back to output then you would access TRIS mode if you wanted to directly set the logic level yourself in an output state. So it seems that there are (3) states of the pins, input, output and the high impendeance setting. Is this why the register configuration port for this option is referred to as "TRIState" or TRIS?

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-02-03 18:17
    This should be in your original thread.· Please do not start new threads for replies to existing questions.· I mistyped my original response.· Almost all microcontrollers have their pins set as inputs by default.· This includes the SX.· When they are made outputs the default is LOW.· However you can write to the port registers when they are inputs, but it won't show up on the pin until it is set to output.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • BebopALotBebopALot Posts: 79
    edited 2006-02-03 21:42
    I'm sorry Chris, I thought I was posting in my original thread, I'm not sure why this is here. This is purely accidental. I'll repost on the original in case somneone else wants to follow then you can nix this.

    Thank you for your help,

    BBAL
  • pjvpjv Posts: 1,903
    edited 2006-02-04 01:47
    Hi Chris;

    Really? I don't have the docs with me (on vacation) but I could have sworn that the power-up default value of an output was indeterminate, and the RESET default value was "no change".

    I could be wrong......

    Cheers,

    Peter (pjv)
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-02-07 01:57
    I guess I will have to double-check that myself.· The BASIC Stamps default that way so I may just be thinking of that.· I don't have my work machine handy right now so I will verify this later.· Thanks for pointing it out though.· Don't want to give wrong information.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • CarlCCarlC Posts: 29
    edited 2006-02-07 02:25
    Power up default of the TRIS reg's are 1 as indicated by my Parallax manual.

    I suspect this is a bit of a protection measure so processors don't try to assert or sink a voltage which may result in a damaging current or cause wonky outputs to a signal bus that your processor is connected to.
  • pjvpjv Posts: 1,903
    edited 2006-02-07 05:12
    Hi Carl;

    The reference was not for the TRIS register, that one we know defaults to inputs on poer-up and reset, but instead to the default contents of the output register once the port bits are turned to outputs.

    Cheers,

    Peter (pjv)
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2006-02-07 07:42
    The SX 28 data sheet states that the port data registers are undefined at power-on, and remain unchanged on all other reset reasons.

    I think it is a good habit to _first_ write the expected output states to the data registers, and _then_ configure pins as outputs in the startup code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-02-07 17:07
    Correct Guenther...I was mistaken in that (thinking of the Stamp Modules).· The RAM also contains unknown data at startup.· So besides setting the outputs to a known state, depending on your application you may also need to clear registers/RAM as well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-02-07 17:16
    Just a not on this subject for SX/B users: SX/B adds code to clear RAM and make all I/O pins inputs unless you specify the NOSTARTUP option.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2006-02-07 22:13
    Chris,

    right, the RAM contents are also undefined at power-on, and remain unchanged on any other reset reasons.

    I think it is a matter of programming style - some programmers prefer to initialize RAM locations specifically before they are accessed the first time, others (like me) prefer to run a "clear all memory" loop at start-up for a "clean start".

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
Sign In or Register to comment.