TRIS
BebopALot
Posts: 79
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 Savage
Parallax Tech Support
csavage@parallax.com
Thank you for your help,
BBAL
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 Savage
Parallax Tech Support
csavage@parallax.com
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.
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)
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 Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
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