CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

help me

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
shooshe



Joined: 04 Aug 2011
Posts: 8

View user's profile Send private message

help me
PostPosted: Fri Aug 05, 2011 3:03 am     Reply with quote

Hi
Good Time
What is TRIS ? Where used?
THANKFUL
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Fri Aug 05, 2011 5:20 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Aug 06, 2011 9:39 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Aug 06, 2011 5:45 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Aug 06, 2011 6:02 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Aug 06, 2011 7:01 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Aug 06, 2011 7:26 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Aug 06, 2011 8:04 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Aug 07, 2011 12:00 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 10, 2011 3:01 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Aug 10, 2011 3:15 pm     Reply with quote

Here is a Microchip tutorial on the PIC ADC:
http://ww1.microchip.com/downloads/en/devicedoc/adc.pdf

ADC setup tutorial for CCS:
http://seng.ulster.ac.uk/eme/sidk/eee305/Miniproject/ADC%20port%20CCS%20compiler.pdf
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group