View previous topic :: View next topic |
Author |
Message |
shooshe
Joined: 04 Aug 2011 Posts: 8
|
help me |
Posted: Fri Aug 05, 2011 3:03 am |
|
|
Hi
Good Time
What is TRIS ? Where used?
THANKFUL |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Fri Aug 05, 2011 5:20 am |
|
|
Chip data sheet.....
TRIS is the tri-state control register. Changes whether pins are configured as inputs or outputs.
Every I/O pin, has an associated TRIS bit.
Where used. Generally, don't!.....
Thing here is that if you were writing in assembler, you would have to control TRIS for every pin. Not only getting it right for input/output, but also for things like peripherals, where there are usually specific settings needed to allow the peripheral to control the pin. So programmers who are used to doing this, keep on doing this. _But_ for 99.9% of code, it is more reliable, to never touch TRIS. Instead let the compiler handle it for you.
So, generally, don't touch the TRIS registers. If (for instance), you perform:
Code: |
output_high(PIN_A1);
|
The compiler knows that you want to output a value on pin A1, and will automatically adjust the TRIS to suit.
So, don't touch TRIS.
Best Wishes |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Sat Aug 06, 2011 9:39 am |
|
|
If you're asking what TRIS is, then I would agree with everything TTelmah has told you so far...
With one caveat:
When you have advanced enough, you will know where and when to touch the TRIS registers yourself as there ARE some good examples of when it's a good idea to turn off the compiler's automatic setting of the TRIS bits when output or input functions are used.
Until then, follow TTelmah's advice knowing some day you will graduate past it.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
shooshe
Joined: 04 Aug 2011 Posts: 8
|
|
Posted: Sat Aug 06, 2011 5:45 pm |
|
|
Thank you for replied this post. I have another question.
What is the address of this ?
Again, thank you.
shooshe |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Sat Aug 06, 2011 6:02 pm |
|
|
TRIS addresses tend to be 80x above the port addresses.
IE : If PORTA is at 5x, TRISA will be 85x.
BUT read the datasheet, EVERY address is listed for that PIC's RAM, ROM, SFRs,peripherals, etc. |
|
|
shooshe
Joined: 04 Aug 2011 Posts: 8
|
|
Posted: Sat Aug 06, 2011 7:01 pm |
|
|
Hi every one...
I know these questions are elementary, Im so sorry but i have,
can u explain a little about the bit_test? What does it do?
thank u
shooshe |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Sat Aug 06, 2011 7:26 pm |
|
|
shooshe wrote: | Hi every one...
I know these questions are elementary, Im so sorry but i have,
can u explain a little about the bit_test? What does it do?
thank u
|
In terms of the C function or the PIC ASM instruction?
If you look at the datasheet for PIC16/18's (and the rest really) there's a chapter on the instruction set.
Just do a PDF for BIT TEST.
Essentially, both function test the bit of some variable and then return true or false based on 1 or 0 at the bit's location.
BIT tests in the smaller PIC's are very fast, a single instruction.
Testing a variable that's 0 or 1 usually requires more machine instructions to execute.
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
shooshe
Joined: 04 Aug 2011 Posts: 8
|
|
Posted: Sat Aug 06, 2011 8:04 pm |
|
|
Dear Ben
Thank you for your attention.
I understand your comment.
It is possible? For this example, I use your guidance?
SHIFTER_DIN = bit_test(Shiftreg, i-1);
Course. This parameter is defined.
Thanks again. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
|
Posted: Sun Aug 07, 2011 12:00 am |
|
|
shooshe wrote: |
SHIFTER_DIN = bit_test(Shiftreg, i-1);
Course. This parameter is defined.
|
This is well defined in the manual for CCS PIC-C.
bit_test returns a value of 0 or 1 based on the test performed.
Cheers,
-Ben _________________ Dazed and confused? I don't think so. Just "plain lost" will do. :D |
|
|
shooshe
Joined: 04 Aug 2011 Posts: 8
|
|
Posted: Wed Aug 10, 2011 3:01 pm |
|
|
Hi every body...
May explain about the setup_adc_ports()?
Of course, I read ccs's help...but i didnt understand very good....
thanks for your attention....
shooshe |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|