Hi, Ambrogio
May I suggest you to open your Holy Manual and just read the INPUT and OUTPUT commands pages ... a look to other commands pages will show you that PBP automatically sets inputs/outputs as desired ... or not !
Alain
Hi, Ambrogio
May I suggest you to open your Holy Manual and just read the INPUT and OUTPUT commands pages ... a look to other commands pages will show you that PBP automatically sets inputs/outputs as desired ... or not !
Alain
Last edited by Acetronics2; - 10th January 2011 at 13:06.
************************************************** ***********************
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 " !!!
*****************************************
Hi,
I found what you suggested to look_at.
When a PIC MCU powers-up, all of the pins are set to input. To use a
pin as an output, the pin or port must be set to an output or a command
must be used that automatically sets a pin to an output.
To set a pin or port to an output (or input), set its TRIS register. Setting a
TRIS bit to 0 makes its corresponding port pin an output. Setting a TRIS
bit to 1 makes its corresponding port pin an input.
So, it is not needed to use tris register !
Am I right ?
Ambrogio
Using many of the PBP commands as you are reading setting TRIS is not needed.
But
as time goes on and your code becomes more complex TRIS will need set. It will be good to get the habit of string TRIS now... or just wait until the code does not work and remember this.
One example would be reading/writing to the port.
Dave
Always wear safety glasses while programming.
Hi, Ambrogio
I' ve taken the good habit ALWAYS to set ALL my Inputs/Outputs with TRIS statements AND aet their respective default level in the first lines of my programs.
of course, all SFR's and variables too ...
Whether PBP ( or any other high level language ) does it for me or not ... so, I'm REALLY sure of what will happen. Especially @ Power-up.
But you can do as you want ... there's no absolute rule !!!
no automatic input setting here ... sooooo you could read an output state !!!If PB=1 then... If PB=0 then...
Alain
Last edited by Acetronics2; - 10th January 2011 at 16:08.
************************************************** ***********************
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 " !!!
*****************************************
I2C is one of those commands that will set the TRIS for you. But like Alain said, you will want to control things at start up. I would set them as an input.I2C requires a pin to be an output and an input for correct communication: what should I declare in the TRIS reg ?
If you have floating pins set them as out puts.
Dave
Always wear safety glasses while programming.
Bookmarks