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 support@ccsinfo.com

#use fast_io(C) set_tris_c() and #BYTE

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



Joined: 31 May 2004
Posts: 86
Location: Colorado Springs, CO

View user's profile Send private message

#use fast_io(C) set_tris_c() and #BYTE
PostPosted: Mon Aug 02, 2004 10:49 pm     Reply with quote

Very Happy
Hopefully a quick question (or 2, or 3, or 4, or 5): Very Happy

I want to use direct io for speed (software PWM with 4 outputs), and have learned that using fast_io will help significantly, but the set_tris_x() function (or changing the register) will be required, and using the #BYTE is needed to directly use a port. I need to do this on Port C while using the UART and I2C functions, and would like to do it correctly so it works.
Below questions are assuming usage of #use FAST_IO(C)...

Questions:
1.) How can I change TRIS_C for the I2C interface, or do I need to? (SDA is bidirectional).

2.) When is TRIS_C) set by the I2C and UART functions? I would like to change TRIS_C only when needed, but using FAST_IO, I'm not sure if I need to set the TRIS_C value for the UART and I2C pins. I know that I at least need to set the TRIS_C bits for the other pins that aren't used by the UART and I2C pins.

3.) Will the compiler do any bank switching needed to access any defined #BYTE directive? (ie: if bank 2 is selected, will the compiler select bank 0 to access PORT_C)?

4.) Is there an expanded FAQ on CCS somewhere? The current FAQ is good, but needs more topics and questions. So far, this forum is the best source of information I have found, but I would like to read a large FAQ before posting stupid questions Very Happy

5.) Has anyone used the I2C interface faster than 400KHz with CCS? If so, HOW? (The part I'm talking to is limited to 3.4MHZ SCL rate, and it should be fairly low capacitance for the connection - no cables).
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Aug 03, 2004 6:08 am     Reply with quote

You need to set the TRIS register at the begining of you program. Go ahead and setup the IO for the RC6 and RC7. I believe the #USE RS232 will do this for you but it can't hurt to do it again and I prefer not to use the #USE RS232 and setup the UART myself. The I2C functions should handle setting the IO. I would just leave them as inputs when setting up the TRIS. Yes the compiler will handle the bank switching. The only FAQ I know about is posted on their site. A PIC running at 40MHz can generate a clock at 10MHz. I2C devices are usually not that fast. Is this a I2C or an SPI device?
bdavis



Joined: 31 May 2004
Posts: 86
Location: Colorado Springs, CO

View user's profile Send private message

PostPosted: Tue Aug 03, 2004 6:34 am     Reply with quote

Mark -

That sounds good Very Happy - I can just setup the tris state before calling the #use rs232 and I2C statements. I'm already using the "fast" and "force_hw" in the I2C use statement, but I think it will go just under 400 KHz, and the I2C part I'm talking to can go up to 3.4 MHz so I wanted to bump up the speed a bit.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Aug 03, 2004 7:00 am     Reply with quote

To go faster, you are going to have to setup the I2C yourself. Read the section in the datasheet. It talks about the Baud Rate generator and you can determine the BRG value needed based on your crystal.
bdavis



Joined: 31 May 2004
Posts: 86
Location: Colorado Springs, CO

View user's profile Send private message

PostPosted: Tue Aug 03, 2004 8:51 am     Reply with quote

Thanks for the feedback Mark -

Do you know if I can just change the BRG after the use I2C() statement, and still use the internal I2C functions?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Aug 03, 2004 10:15 am     Reply with quote

You should be able to. You can look in the lst file to see what the #use i2c is doing and when it is called. I like to set things up myself to avoid any confusion or changes that could be made in the future.
bdavis



Joined: 31 May 2004
Posts: 86
Location: Colorado Springs, CO

View user's profile Send private message

PostPosted: Tue Aug 03, 2004 11:16 am     Reply with quote

OK - Thanks Mark!
I'll give that a shot...
Guest








PostPosted: Mon Feb 06, 2006 5:01 am     Reply with quote

Mark wrote:
You need to set the TRIS register at the begining of you program. Go ahead and setup the IO for the RC6 and RC7. I believe the #USE RS232 will do this for you but it can't hurt to do it again and I prefer not to use the #USE RS232 and setup the UART myself. The I2C functions should handle setting the IO. I would just leave them as inputs when setting up the TRIS. Yes the compiler will handle the bank switching. The only FAQ I know about is posted on their site. A PIC running at 40MHz can generate a clock at 10MHz. I2C devices are usually not that fast. Is this a I2C or an SPI device?
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Mon Feb 06, 2006 9:35 am     Reply with quote

This guy seems to have some spare time on his hands to be posting so many phantom messages.
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